Most reputable rental shops keep helmets on hand, either included in the price or for a small add-on, because tourists ask and liability encourages it. Quality varies from genuinely good to sun-bleached shells with tired straps, so give any loaner a quick check: snug fit, working buckle, no cracks. Bike-share schemes are the gap in the system, since dockless and docked apps almost never supply helmets, leaving compliance entirely to you in places that require one.
Whether the law obliges you to wear it is a separate question that depends on the country and sometimes the city. The common patterns worldwide are: no mandate for adults on regular bikes, a child-only mandate up to a set age, or an all-ages mandate in a minority of countries, with e-bikes and e-scooters often carrying stricter rules than pedal bikes. Fines where they exist are typically small on-the-spot penalties, but police in tourist zones do issue them.
Ask the shop directly what the local law says, since they answer that daily, then verify anything surprising against the official road authority page. And when in doubt, just take the helmet they offer; it is the cheapest risk reduction available.