Just some updates on this experiment.
I have updated the program to use websocket for sending and receiving messages in real time, then set it up as a service and ran it for 2 days. Built a quick-and-dirty webapp to test the backend as well. It is not too bad - didn't feel any unusual lag and it consumed just 6-8% more battery per day, but I didn't have a lot of WhatsApp messages so didn't open the webapp frequently.
To be honest, putting the whatsmeow backend onto a cloud server makes more sense, but putting it inside the phone is technically possible. I think this satisfied my curiosity.
Here is a video in case you are interested in seeing if there is any delay in sending/receiving messages: