Legal requirements are usually clear on paper: licensed taxis in most countries must use a sealed, calibrated meter for standard trips, with official fixed fares permitted on airport and station routes. Enforcement is the variable, and destinations range from strict compliance cultures to places where the meter exists mainly as decoration for tourists.
Handling an unmetered situation depends on which world you are in. In a metered-culture country, simply decline and take the next cab; a refusal there is a red flag about the whole ride. In a negotiation-culture country, unmetered street taxis are normal, so the skill is agreeing a firm total before departure, covering all passengers and luggage, anchored to a ride-hailing app estimate you checked beforehand, which reveals the fair rate for any route.
For overcharges after the fact, your leverage is the taxi license number displayed in the cab and on the plate. Photograph it, pay roughly the fair amount, and file with the taxi authority or tourist police; cities with tourism economies process these complaints seriously. Prevention beats remedy though: official ranks, prepaid airport counters, apps with upfront pricing, and small bills so the no-change routine never starts.