If you have Simscape Electrical, you can use the Variable Capacitor that accepts C as a Simscape Physical Signal.
You can measure voltage over the capacitor and apply some transformation/lookup table to feed in into the C signal:
Please stay within "Simscape World" and use Simscape Physical Signals (brown Simulink-like blocks) to deal with Physical Signals insad of going into Simulink. This will make the simulation more stable.
If you don't have Simscape Electrical, you can build your own Simscape based component block using Simscape Language: