It is illegal because of the intent to cause harm.
If someone overhears you saying you added hot sauce to hurt them, not because you like hot sauce, then you could be legally on the hook for poisoning or assaulting them. Setting traps for humans is illegal, even if they are on your property and/or the victim has to have committed a crime to trip them. In this case it doesn't matter whether you add a reasonable amount of hot sauce.
If you kept your mouth shut you might still be in trouble if there is evidence that you intended to cause harm. If you normally don't put hot sauce on your food, and out of the blue you put an unreasonable amount of very hot sauce on your food, then your intent to harm might be established, especially if the first time you try this they don't take the bait and you avoid eating the food yourself. That shows your motivation wasn't to eat the food yourself, and leaves only the motivation of setting a trap for your coworker.
Where, legally, that leaves people who genuinely like hot sauce on their lunch? I can't find any precedent of someone getting in legal trouble like this. If the intent is not to cause harm, then some duty of care+negligence would have to be established. I think the first roadblock to such a case would be that it's reasonable to expect that food might contain a reasonable amount of hot sauce, even if the label (or lack of label) doesn't indicate that.
So your own intent to do this for the purpose of causing harm is what makes this illegal. (I would note, however, that if you left something truly horrifyingly spicy, think highest on the Scoville scale, something that makes spicy-entheusiasts cry, unlabeled in a random public fridge, it could be found negligent, even if you didn't mean to hurt anyone)