I know little about scripting, but here's a solution using events:
Set up a common event in which you set the actor's HP, SP, etc. to a variable. Then, after transformation, restore it to the variable. Do the same thing for ending a transformation.
I've never tried this myself, but thinking through it I don't see any reason why it shouldn't work.