What exactly do Non-Disparagement agreements cover? Is there some kind of implied limitation, such as it has to relate to the work?
Black's Law Dictionary defines disparagement [of Goods] as "A statement about a competitor's goods which is untrue or misleading and is made to influence or tends to influence the public not to buy". This gives a basis for inferring the scope of disparagement of a company itself (rather than just of the goods and services it provides), and how it applies to the scenarios you outline. Not every negative statement about a company or its agents meets the definition elements of (1) competition, (2) falsehood, and (3) deterrence of [potential or actual] counterparties.
an employee who signed this comments on a picture on social media that someone is wearing an ugly shirt and that person happens to be a stockholder
An opinion on social media regarding someone's ugly shirt clearly fails these three elements unless the company is in the business of producing/marketing that type of shirts. Even if that is the company's business, an actual opinion is not a fact, and therefore it is not susceptible to a test of veracity.
How would the person signing it even know if a person they are making a disparaging comment about fits in one of the above categories
Unreasonable clauses are stricken as null and void, and in many contexts it is unreasonable to expect an employee to guess or know all of the "current or former officers, directors, stockholders, partners or employees" at the time of making his statement.
What if it's a matter of fact, like the company was late paying it's employees (assuming this was true)
A truthful, non-exaggerated statement about the company's belatedness is not actionable because it is not false or misleading.
What if it's a matter of opinion like "I wish I didn't have to wear a tie to work"
It is extremely unlikely that such statement of opinion harms or tends to harm the company at all. For instance, no employee would leave the company only because you don't like wearing a tie at work. Nor would your preference discourage candidates from joining the company. What could discourage them is the underlying obligation to wear a tie, not a person's opinion about that obligation.