That's a great question, and one that many people wonder about when they're out and about in the city. Generally speaking, most public trash cans provided by city municipalities do come with liners. These liners are standard-issue plastic bags that sanitation workers use to quickly and hygienically empty the bins during their collection rounds.
You typically do not need to bring or buy your own liners for public receptacles. The entire system is managed by the local public works or sanitation department. Their crews are responsible for installing a fresh bag after each collection to prevent mess and control odors.
However, there can be exceptions. In some parks or less-frequented areas, you might occasionally find a bin where the liner is missing, perhaps because it was recently emptied and not yet re-lined, or it tore from overfilling. In such a case, it's still best to place your trash inside the can. The system is designed to handle this, and the workers will clean it out regardless.
So, for your daily walk or commute, you can rest easy. Your responsibility is simply to get your trash into the can. The city handles the rest, including supplying the liners. It's always a good practice to make sure your garbage actually makes it into the bin, which helps keep our shared spaces clean for everyone.