There is a possible solution, but you must adapt it. An example is here, given by @unman:
It is designed to be created as an executable script in dom0…
If you are comfortable with shell scripts, then it should be easy to understand. I do recommend to change the shutdown commands to qvm-shutdown --wait ....
to be sure that the shutdown finishes before trying to change the template.