I'm definitely not suggesting either Joseph or Esther broke this prohibition (at all, or at worst unless it was necessary to save life or other exceptions granted by the Torah). I have little knowledge of the answer either way but assume the best. I only ask the question as a thought exercise to better understand the distinctions between when it is encouraging idol worship and when it isn't.
The pharaohs in Egypt considered themselves gods, and many in the population were ignorant, uneducated, poor, and believed it (or just idolatrous by nature regardless of those factors). Joseph became #2 in the nation, and had the attire to go with the position. How did he assume that title of vizier under those circumstances, and embody that position and all that went with it, without encouraging others in the court and the Egyptian citizens to idol worship him?
Same idea in Persia with Esther. In order to get Achashverosh to want to marry her, she may have had to look attractive and appeal to his physical, egoistic nature. At least, it seems like his type might have not seen her inner beauty most of the time, and that he might have looked at her as more than a trophy, in some sense an idol. He may have idolized her beauty and so on. So if his attention was of an idolatrous nature, then if she ever had to wear nice clothes and so on to keep his interest, did she encourage him to idol worship? (This is definitely not suggesting she did anything to bring any horrible treatment on herself, absolutely not, please do not misconstrue it that way. And everything she did was needed for the Jewish people to be saved. I only mean it as a way to ask the halachah question).
I also think it's a relevant question to today for anyone who works in the public domain in any type of job that is popular, that people will idolize. If you become the best violinist in the world, and you play publicly, there is going to be 1 out 10,000 or however many who comes to see you play, and is trying to learn themselves, who may come to idolize you (not always the same as idol worship but sometimes), and put pictures of you up all over their room, and make you a hero of their worship in some sense. Have you then encouraged idol worship? And that's not even a profession where the public nature of it has a really big "brand promotion" culture. What if you are an entrepreneur in such a business and you are promoting yourself and your "brand" via social media in order to build your business, and you sell a luxury lifestyle, and your personality and projecting an attractive image are central to promoting your business model? Have you encouraged idol worship?
I know there are certain exceptions for certain prohibitions, so I'm presuming that will be part of the answer, and I would also like to get into the distinctions of when being popular or powerful crosses the line into encouraging idol worship even in cases you don't have an exception because of a different category, if that makes sense, as well as into those distinctions and when they do and don't apply in such cases. Thank you/Toda rabah.