I once was employed by a German company being a UK resident. They made me resident in Germany for the time it took them to register a UK branch of the company. (This was pre-Brexit). Once that was done, I was able to keep working in Germany but as UK resident.