Check the cat for illness or injuries.
Suddenly and uncharacteristically lashing out could be a sign of pain. Even cats that are normally very tolerant can be very aggressive when it feels you are hurting it. For instance, we had a similar incident with one of my cats when someone tried to adjust its collar. It turned out the cat had gained enough weight since the collar had been put on that it had started rubbing the cat and made its skin sore, and adjusting the collar rubbed the sore area. That was enough for the cat to swipe pretty viciously.
However, pain might not be caused by a visually obvious ailment. So also keep an eye on it to see if you notice any other signs, such as changes in how much it's eating, or how much it's using the litterbox, or any other habits. Similarly, keep note of exactly how you were handling the cat when this happened. You might be able to guess which area exactly might hurt, if some place does hurt. Or if it happens again, then you might be able to notice a pattern and figure out if it's a specific spot that hurts.
Obviously if you do suspect it's pain, then you should arrange a vet visit.
If any sort of medical problem is ruled out, I would guess that either the cat was startled, or you accidentally handled it in a way that it didn't like. Even cats that are normally pretty well socialized can be very jumpy or unexpectedly sensitive. Sometimes they will go from being content to irritated with not much obvious warning. Or sometimes the warning signs are really subtle. The tail might start twitching a bit, the cat becomes more alert, the ears swivel back ever so slightly, and the cat becomes a bit tense.
It is even possible that as you say, the cat didn't recognize you when wearing the hoodie, or that was surprised by the change of appearance. Cats do use vision to identify their owners to some extent, so sudden unexpected changes in their owner's appearance does frighten them sometimes.