Q. It is customary to bow to the judge in court. Is this permitted according to Halacha?
A. Remoh (Y.D. 150: 3) rules that one may bow or take off one's hat for a king or minister if he has not declared himself to be divine and is also not wearing any Avoda Zara symbol.
Many instances of bowing or kneeling are recorded in Tanach as permitted, when done only for respect or esteem. Avraham Avinu prostrated himself before the people of the land. (Bereshis 23: 12) Yosef's brothers prostrated themselves to him, with their faces to the ground. (Bereshis 42: 6).Yaakov even prostrated to Eisav seven times and the prophet Natan prostrated to David (Melachim 1:1:23)
However, Mordechai's refusal to bow to Haman was due to the fact that Haman declared himself to be a deity (Rashi Megilas Ester 3:2, Ralbag and Midrash Lekach Tov) or was wearing an Avoda Zara symbol. (Ester Rabbah (7:6), Ibn Ezra on Megilas Ester 3: 3 and Tosafos Sanhedrin 61b)
Rav Chanoch Teller, in his biography of Horav Aharon Kotler zt”l, relates that Rav Aharon zt”l once was in a post office in Japan in 1940 when a siren sounded alerting that Emperor Hirohito was in the area. The law in Japan at that time was that anyone who did not bow to the ground when the siren sounded was to be put to death. Rav Aharon Kotler refused to bow down, invoking the precedent of Mordechai. Rav Aharon was beaten severely, but his life was spared
Horav Shlomo Miller Shlit'a related that when Horav Eliezer Silver zt”l met Eleanor Roosevelt she greeted him by stretching out her hand. Quick thinking Horav Silver reacted by taking off his top hat and bowing down to the first lady.
Rabbi A. Bartfeld as revised by Horav Shlomo Miller Shlit”a