Yes)) Any driver is possible to rewrite in any way) The real questions would be "Who?", "When?" and "How fast?" )))) (a bit of joking)
The driver with the exact such behavior already exist. Shelly Device Handlers for Hubitat - #448 by Evilborg
Absolutely yes. Though I would recommend to ask the author permission to use his code as the base just in case)