You can pick one up by winning the game "Towing the Line" in The Robot Chronicles. It is a prize rather than a purchase, so it comes down to playing that mini-game until it pays out.
The original answer also included a username and an invitation to visit, which has been dropped — posting your account name in a public answer just invites strangers to message you. If the hard hat will not drop, check whether the mini-game has a score threshold you are just short of.