The answer to your question is "yes"..... something similar to what you ask can be done... and there are several options that are available.
This one is the simplest valve and would be automatic with no human intervention required. The valve is normally open when power is applied to it. If you can wire it so that power is applied when the engine is running, it will automatically be open. As soon as the engine stops and power is no longer applied to the valve, it would close. We would need to look at boat schematics and find a circuit suppling 12V only when the engine is running to have the valve alway open then close when it shuts off.
Here is a video showing how it works.
This valve is more fancy and can give you several options. It can be wired so that you can switch the valve open or closed. You can also wire an indicator light on the dashboard to let you know if it is open or closed. This one will give you peace of mind but requires you to remember to open or close the valve.
Here is a video showing how it is setup and how it works.
The above valves are stainless steel but they also make UPVC and brass options. They also come in multiple sizes. Here is the website:
U.S. Solid Motorized Ball Valves are two-way(two ports or two openings) quarter-turn ball valves. The motorized ball valves here are not for regulating flow, they can be fully opened or fully closed automatically receiving a control signal. We also carry a variety of different types of wiring...
ussolid.com
My old SX192 would have been easy. I would really like to do it on my 275SD but it is tough to get to the water intake lines the way it is designed and you would need ot be a contortionist.... so I shelved the project.
I would have selected the auto-return valve because it is automatic.... engine is running, the valve opens. The engine shuts off, the valve is closed. I would think you could wire an indicator light into as well so it was on when 12V was being applied to keep the valve open.
I'm rack storing my boat and they flush the engines for me each time before the stow the boat. I have to rely that they will do it properly. I wrote detailed instructions and laminated them. I keep a set on the captain's seat when I leave and I built my own flush hose with shut-off valve and I attached another laminated copy of the instructions to it.
The yard guys should never make a mistake but we all know $hit happens. If I had the auto-return ball valve installed for each engine, it would be idiot proof.
This would also make towing the boat on the water safe and simple.
I have used these stainless steel electronic ball valves in my motorhome; one for draining the fresh water tank and one for filling the fresh water tank when I am hooked up to city water. I have mine wired so that I use a wireless switch with a small keyfob remote control to open and close the valves when I want to drain the water tank or fill it. In 4 years of use I have never had either valve fail or leak.
Here is the wireless switch I use: