Simple, when a dummy spell that targets nothing is cast by the hero you want to change, you hide the hero and change its owner to another non controable player like neutral passive. You then decide which hero you want it to turn into, if its random you make a random system, otherwise if the player can choose you just use the variable containing the players desired unit type. Then you make it create the selected hero type at the location of where the other hero was hid, this gets you your looks. Finnaly you add the abilities to it and set their levels to what the orignal hero had, and also set the new heroes stats to what the old hero was (level included).
After this your hero transformation system is done, but to revert. . .
You will need to, appon finishing morphing, add a expiration timer to the unit via triggers with the type of metomorphisis so the text is correct. When that timer expires, you remove that dummy hero and then fetch the old orignal hero back to the player. Then you move it to the facing of the dummy and the location of the dummy hero and set its exp and stats to what the dummies was to prevent exp loss.
Although this sounds rather complex, it actually is very simple.