That's a great question, and one I've actually looked into myself! The short answer is yes, you absolutely can add a locking mechanism to a standard urban trash bin, though it requires a bit of ingenuity since most curbside bins aren't designed with locks from the factory.
The main reasons people want to do this are to prevent scavenging by animals like raccoons, to stop casual theft of the bin itself, or to discourage others from dumping their household waste into your bin (which can be a real issue in some neighborhoods).
For a simple DIY solution, you can use a bungee cord with hooks, a sturdy strap with a buckle, or even a length of chain with a carabiner. The idea is to connect the lid's handle to a handle on the bin's body, preventing the lid from flipping open freely. For a more secure lock, you can drill small holes through the lid lip and the bin's rim and use a small padlock or a cabinet lock. Just be careful not to compromise the bin's structural integrity.
Important caveat: First, check with your local waste management authority. Some municipalities have rules against modifying city-provided bins, as it could interfere with automated collection trucks. If it's your privately purchased bin, you have more freedom. Also, remember that the collection crew needs to be able to empty it. Any lock must be easy for you to remove on pickup day, or you must be present to unlock it.
For a hassle-free route, consider buying a commercially available "locking trash can" designed for outdoor use. These often have integrated, easy-release locks built into the design. While it's an extra cost, it's often the most reliable and neat-looking solution.
So, while your standard rolling bin isn't lock-ready out of the box, with some simple tools and a check of local rules, you can definitely make it more secure.