scratching him where?
If I scratch a horse, and he wants to push back against me, I tend not to hold that against him, but I don't allow him to swing his shoulder or hiney smack into me. and if he keeps doing it, I just go scratch another horse who will enjoy without pushing on me.
I guess I would not initiate scratching in a horse that typically nips, or if I did, I would have my hand ready to turn his head away if he starts turning toward me (if I am at his shoulder) . if they aren't really going for you but just reaching around, then a finger tap on the side of the face is enough to remind them to keep facing forward.
If he really nipped me, I'd probably give a big smack, like as hard as I could and very fast, but would be less inclined to want to scratch such a horse again.