Are there countries, in which, a visiting foreigner under some kind of visa, is able to change their name, through that country's laws (and not the laws of their country of origin)? Or is this available only to permanent residents? It can be a new name just to use while being in that country. Like issuing a certificate of a temporary alternative name. I guess the passport name won't change because it's issued by the home country.
In the UK you don't need to do anything to change your name, just start calling yourself something different, but institutions usually require to use a Deed Poll [1] to have something officially looking that shows your new name. You can fill in a deed poll even if you're new to the country and don't plan on settle down, although it's usefulness is of course limited that way.
You can then use the deed poll to change your name on your driving licence, which is usually accepted at most institutions. However some of them might still want to check your passport, and won't like it if your name there is different to the one on your passport, see my answer on a different question [2].
[1] https://www.gov.uk/change-name-deed-poll/overview