Yes anybody can take the UK amateur radio exams from any country. You can take the exams online and book the exams on the RSGB website. There are 3 levels of Licence, Foundation, Intermediate and Full.
If you are temporarily visiting the UK you may be able to operate in the UK using your existing Licence. CEPT T/R 61-01. For operating in the UK longer-term you may be able to show your existing amateur Licence to Ofcom to get a UK Licence. (It depends on what type of Licence you have).
Once you pass the UK Full exam you will be sent a HAREC certificate in the same envelope as the Full pass certificate. Someone with a HAREC should be able to get an amateur radio Licence in other participating countries. CEPT T/R 61-02.
You do not need a UK address to take the UK exams. RSGB will happily send certificates abroad. You can use a local address (outside the UK), to apply for a UK callsign once you have passed the exam.
Please Note that to apply for a UK amateur radio licence you will need a UK main station address to qualify.
You don’t have to live at the address, and you don’t need to have any right to live in or even enter the UK. You do not need a UK address or callsign to get a HAREC certificate. It is sent in the same envelope as the Full pass certificate.
Source: Spoke directly to Ofcom to clarify these questions.
OARC Wiki Training page
Training page
Online training resources
https://rsgb.org/main/clubs-training/for-students/online-training-resources-for-students/
Booking your amateur radio exam
https://rsgb.org/main/clubs-training/for-students/paying-for-your-exam/
Licensing guidance document for amateur radio – Ofcom
https://www.ofcom.org.uk/siteassets/resources/documents/manage-your-licence/amateur/amateur_radio_licence_guidance_for_licensees.pdf?v=368087
CEPT T/R 61-01 Document
https://docdb.cept.org/download/2ae38a89-e58a/TR6101.pdf
CEPT T/R 61-02 Document
https://docdb.cept.org/download/2569