It is hard to prove the negative, but there does not appear to be any blanket prohibition. Indeed, Hasdai ibn Shaprut was physician and unofficial vizier to Caliph Abd-ar-Rahman III. R. Shmuel HaNaggid was similarly the vizier of Badis ibn Habus. Rambam was similarly the court physician of the Grand Vizier Al Qadi al Fadil, then to Sultan Saladin, after whose death he remained a physician to the royal family. Similarly, his son R. Avraham inherited this role of court physician. Similarly, R. Isaac Abravanel was the treasurer of of King Afonso V of Portugal. Similarly, R. Samson Wertheimer was the court Jew of Emperor Leopold I.
Significantly, in his commentary to the Mishna, R. Ovadia of Bertinoro explains that this means that those who have contact with the government should be careful. That is, the intent isn't to not work for the government, necessarily, but to be careful.