I wish this was possible. The current API (as much as I've explored it and tested it) does not properly work when placing waterfill. Many of the events that should be triggered are not at all and some stop being triggered as soon as a death (player or entity) occurs.
Aside from the "bugs" (I have yet to determine if this is a factorio bug or just a not supported thing in factorio) there also is tile masking which allows you to somewhat limit where one can place certain tiles. However this masking only works on tiles and can not check for entities at all (this is a Factorio design choice and changing this would significantly slow down the game which the devs won't do).
I do want to make waterfill more safe but currently I have no reliable ways of doing so.