We had an alarm to tell us when mother was on the move, so she would not walk outside without us knowing, clearly health and safety did not want to lock her in the house.
However the problem was alarm unit upstairs to alert us if she wandered at night, so some one knocking the door, required us to run upstairs to turn alarm off first.
We tried many ways to be able to switch off alarm remotely, timers and remote controlled sockets, in the end used a smart socket that combined times and remote controls, however it was expensive. But unlike children with second childhood one can't teach the person to behave better.
My children soon learnt that they could get up the stairs by squeezing between the open plan treads, we realised it was safer to teach them how to use stairs than to simply try and stop them. The time scale between dangerous for child on stairs to safe for them to use is quite short, so never went to great lengths, and grandchildren were not in house long enough to learn how to get around the gate.
So yes you can fit an alarm, but question is if worth it? Some times education is better than physical barriers, including showing people how to close a gate.