For tourist location it work. Government gets the money back in sales and other taxes. But in other cities it will be money pit with no possible way to recoup the cost. It can never work in rural areas because there isn't a dense enough population.
They can’t recoup the cost of roads but that doesn’t stop them from building and maintaining a ton of them. Public services don’t have to pay for themselves directly.
There are small towns like Corvallis, Oregon that do this because there's a need for transport around the university. The rest of the ridership might be mainly disabled/elderly who wouldn't pay much anyway. So the cost of administering a ticketing system isn't worth the revenue. Basically systems that don't have working commuters.
https://www.corvallisoregon.gov/cts
I think in rural areas there is still a benefit in running shuttles between towns. For example running an hourly shuttle between two towns of 1k-5k 20mi apart
Dunkerque isn't exactly a tourist location! At least for French people. It's in the north of the north so it has worse weather than most places (the North is notorious for its rain and cold compared to other places, everything is grey.). Every French person will tend to go south to their hometown when going on vacation.
> it will be money pit
This is not a given at all. You have to consider the cost of enforcing the payment system. If transport is free you don't have to maintain the turnstiles and gates, employ verification agents, create cards, print tickets, etc. It's not clear at all that fares are covering this cost by themselves. Public transport is already greatly subsidized and already free or cheap for large parts of the population (elderly, disabled, unemployed, students, children).