How is an "out-of-trim" condition like the one mentioned in the linked question detected on the ground? I.e "out-of-trim" in the context of weight distribution or balance of the aircraft and not control surface trim.
Most likely there was a last minute passenger and/or cargo adjustment.
One checklist item to be done before takeoff is setting the elevator trim. For this, you plug in the numbers (weight of each cargo section + passenger section + fuel), then the computer will tell you the trim value.
Of the entire trim range, only a portion is valid for takeoff. Say the range is 0-10, but you can only takeoff with the trim set between 6-8.
The pilot input the numbers and found the result to be outside the permitted range for takeoff.
In case you are wondering, there are no weight sensors on the gears. On the ground, Weight & Balance is calculated, not measured.
The most likely scenario, where you have an unforeseen deviation from plan at the last minute, is pax loading where due to a statistical fluke there is an uneven distribution of pax in the cabin, say because a lot of them didn't show up and the no-shows tended to concentrate toward one end.
When the FAs inspect the cabin after boarding, they do a pax count and one thing they are looking for is a minimum number of pax in each cabin weight and balance zone. If the FA sees something that is out of whack, like the front half of the cabin near empty with a crowd at the back, they will let the Capt know, and if necessary will start going around to pax to request them to change seats to address the under filled zones.
For cargo, the crew has to trust the people that loaded the cargo weight and balance wise. For fuel, it's mostly about making sure the fuel load indicated in the cockpit matches the fuel load paperwork and the weight and balance load sheets and trip requirements.
In a line operation, the crew doesn't have to do any of the actual dirty work, they are just presented with the information prepared by specialists and review it to make sure it jives with expectations and requirements.