If I don't want a hug from someone, where ever it happens, I step back and evade the hug. Or say please don't touch me, or let go or whatever works.
I tend to be a very touchy feely person, and love giving and receiving hugs but that doesn't mean I accept/allow hugs from someone I don't want to give me a hug.
It sounds a litte silly but hugging can be considered assault (or is it battery?) when it is unwelcome. No one has the right to touch me without my permission.