If you want to revarnish the windings of the transformer, spray paint will only cover the outside, and not penetrate through all the windings, so if it was a short that you were trying to fix, maybe re winding it or getting another would be a better option, but if you just want to paint the outside, spray paint should be fine.