Should be exceedingly easy. Just a "wet" sensor connected to a controller and thence to a solenoid valve.
Of course, as always, the devil is in the details.
1. What power source? AC line? battery?
2. What type of solenoid valve?
3. You probably want the valve to energize (shutting the valve), then have it de-energized in the closed position.
4. You obviously need some way to reset the system to open the valve. How: manually? electrically?
Electronically, this should be very easy to implement, once the blanks above are filled in.