It already happens all the time. It even has a name.

https://en.wikipedia.org/wiki/Stalkerware