Yes, that is how solar controllers work normally.
Now, a grid-tie charge controller+inverter has one job: Shove as much power as possible back onto the grid while the grid is up, and shut off entirely (per UL 1741) when the grid is down.
But plain (DC) charge controllers coupled to a battery, need to throttle their output up and down so they charge the battery at appropriate rates and "tail off" the finishing charge as the battery nears 100%. This varies "on the fly" based on whichever DC loads are being powered.
It is no problem for the controller to reduce its draw to less than the solar panels are capable of putting out. If the controller reduces its draw, solar voltage will rise. But it will not rise infinitely; it will stop at the panel's float voltage (commonly 19V for a "12V" panel). At that point, instead of making power, the solar panel will just sit there getting warm, but that does not harm - it'll get no warmer than any other black thing sitting in direct sun.
Dump
Better-featured DC solar charge controllers have a third set of terminals called "DUMP". The charge controller provides DC power to these terminals when the solar is making more than can be put into battery + direct loads.
A DC charge controller with "Dump" make the water heater exercise rather easy: simply route the "dump" power to the heater.
The "dump" power could be fed through a DC-AC inverter to make a correct voltage for the heater (which needs to be AC because switching 120/230V DC is very difficult, and AC-rated heaters are not rated to switch DC). This could then pick up a DPDT contactor which would switch the heater from utility to solar when solar is present. However, here's another thought.
Many water heaters have 2 heating elements, and only one is used at a time based on circumstance. The water heater could be "hacked" to use one heating element for utility AC, and the other element replaced with a DC element of your system voltage. This would reduce overall heater performance (it has 2 heaters for a reason) but would allow you to capture the excess energy.
Or water could be recirculated between the water heater's bottom drain valve and a "tee" off the cold water inlet, using a small pump and an inline heater. This would need to be well insulated or it would defeat the purpose.
Temperature management
You have to plan temperature carefully. You cannot have water sitting in a heater tank much below 60C (140F) or it will breed legionella and other bacteria. (and if this is news to you, it's because it's fairly new science). This already requires thermostatic faucets. So you can push temperature higher, e.g. up into restaurant dishwashing temperatures, but you can't go near 100C or you'll over-pressurize the heater and make the safety valve dump water all over your floor (or worse: fail to do so, causing a BLEVE!)
Your best bet might be a timer -- which switches the water heater from utility to solar in the morning just before you do your morning bathing (so that depletes its hot water and gives the dump energy something to heat)... and switches it back at dusk or whenever the favorable utility rates kick in.
It takes longer than 12 hours for bacterial growth to flare up significantly in a water heater, so as long as it's getting heated to ~60C every night, that will definitely kill the bacteria.