
From Gil Student here: https://www.torahmusings.com/2011/01/bareheaded-and-uncensored/
“R. David Zvi Hoffmann was the leading halakhic decisor in Germany at the turn of the twentieth century. A brilliant Talmudist and academic scholar, he succeeded R. Azriel Hildesheimer as rector of the Orthodox rabbinic seminary in Berlin.
His influential collection of responsa, Melamed Le-Ho’il, were posthumously published by his son. They have since been repeatedly republished, but always offset from the original edition. This made the omission in the latest edition very obvious — the missing responsum was replaced with empty space!
(Note: the question and answer is here thanks to Hebrewbooks: https://www.hebrewbooks.org/pdfpager.aspx?req=1053&st=&pgnum=194 – RH)
The “offending” responsum answers a question regarding swearing in court while bareheaded, as was standard secular protocol at the time. In his response, R. Hoffmann recalls the teaching job he held as a young rabbi in Frankfurt. Students learned secular studies bareheaded in the school founded and headed by R. Samson Raphael Hirsch. When R. Hoffmann went to visit R. Hirsch for the first time and failed to remove his headcovering, R. Hirsch berated him because other staff members may interpret it as a sign of disrespect. R. Hoffmann compared this with the strict views of Hungarian rabbis, who particularly forbade students in school to study bareheaded. R. Hoffmann concluded that litigants should request permission from the judge to swear while wearing a hat but if the judge refuses, they may swear bareheaded.
While R. Hoffmann was censored in the past, he has now been redeemed by his great-grandson and namesake. R. David Zvi Hoffmann of Jerusalem recently published a retypeset edition of Melamed Le-Ho’il. This new edition contains translations into Hebrew of all the German — a major improvement — and an extensive introduction by the contemporary R. Hoffmann. This proud descendant not only included the previously censored responsum, but highlighted it with a note in the table of contents.”

Here’s the full text:
ש א ל ה :
אי רשאי לישבע בערכאות שלהם בגילוי ראש.
ת ש ו ב ה :
אין לי פנאי להאריך כעת. אבל עיין בכנה״ג לי״ר סי׳ קנ״ז דמיקל
בשעת הרחק. ועיין בבית לחם יהודה ושער אפרים שהביאו זה ורומז על שר״ת
ועיין גס בבית הלל לי״ר סי׳ קנ״ז דהיו נותנים שוחר שלא יצטרכו לישבע
בגילוי ראש. והנה בעת הזאת הרבנים היראים כמדינות אוננארן סחסירין
סאר בענין גלוי ראש, עיין הבירור מש״ש ופוסקים בשו״ת נחלת בנימין סי׳
ל׳. והנה הגר״א בהגהותיו לס•׳ ח׳ ס״ק ב׳ העלה שאין איסור אפילו להוציא
אזכרה בג״ר אלא סירת חסידות. ומ״ש שם בתשובת נחלת בנימין שאם
בבית חנוך שמו לחוק שצעירי ישראל צריכין לישב דוקא בפריעת ראש
ועושין כן ע״ר אביהם וראשי הערה, זה איסור גמור משום ובחוקותיהם ל א
תלכו. הנה בק״ק יראים רפפר״ם בבית החינוך שנתיסר מהגאון ר׳ .שמשון
רפאל הירש זצ״ל (שאני הייתי מורה שם ב׳ שנים וחצי) יושבים התלמידים
בשעת לימור שאר המרעים בפריעת ראש, ורק בשעת לימור תורה מכסים ראשם
(וכן הוא המנהג בבית הספר בהאמבורג) ווה ;עשה שם עפ״י תקנת הרה״ג
מו״ה ש״ר הירש זצ״ל. ובפעם ראשון שבאתי לביתו של הרה״ג ש״ר הירש
בכובע על ראשי, אמר לי שכאן הוא דרך ארץ להסיר הכובע מעל הראש
כשבאין אל ארם חשוב, ואולי יראה מורה אחר (יש בבית החינוך שם נם
הרבה מורים א״־) שאני איני מסיר הכובע מעל הראש לפני ראש בית החינוך
(דירעקטיאר) היה מחשב זה כאילו אני מבזה אותו. ובזה וכיוצא כזה אין ב ו
משום בחוקותיהם. — ואם כן בנידון רירן אם השופט נותן רשות לכסות
הראש בשעת השבועה מה טוב, וכל אחר בוראי לכתחלה צריך לבקש
מהשופט לכסות ראשו ויאמר כי הוא מצווה לכסות ראשו בכל דבר
שבקדושה והשבועה הו־א לו בלתי ספק דבר קדושה. אמנם אם השופט אינו
רוצה לתת לו רשות א״צ לקבל עליו אפי׳ עונש ממון ויכול לישבע אפילו בגילוי
ראש, וכן פסק מהרא”י בפסקים וכתבים לסי׳ ר״ג, ע׳ שו״ת יריעות שלמה
חלק א׳ ועיין בכור שור לשבת רף קי׳׳ח ע״ב דהיכא שנראה מתוך מעשיו
דלאו משום חוקותיהם שרי וע׳ בשו׳׳ת חיים שאל ח״ב סי׳ ל״ה (רפוס
ליווארנא) אי רשאי לברך בגילוי ראש וגם מדבר שם אי יש לו על ראשו
פעריקקע, פסקים וכתבים של מהרא״י סי׳ ר״ג מתיר לישבע בגילוי ראש
(אך צריך לי לעיין שם בפנים).
English translation (ChatGPT):
Question:
Is it permissible to take an oath in a non-Jewish court with an uncovered head?
Answer:
I don’t have time to go into this in detail right now. However, take a look at the Kenesses HaGedolah on Yoreh Deah, Siman 157, where he is lenient in cases of pressing need. Also, refer to Beit Lechem Yehuda and Sha’ar Ephraim, who discuss this and hint at the approach of the Rema. Additionally, see Beit Hillel in Siman 157, which describes a case where efforts were made to avoid having to swear with an uncovered head.
In our times, rabbinic authorities in places like Hungary and Germany have deliberated extensively regarding uncovered heads. See the clarifications of the Nachalat Binyamin in Siman 30, which cites various rulings on this matter. The Vilna Gaon, in his notes on Siman 8:2, writes that there is no outright prohibition against pronouncing the name of Hashem with an uncovered head; it is a matter of piety.
The Nachalat Binyamin also notes that if a law in secular schools requires Jewish youth to sit with uncovered heads, and they do so due to pressure from their parents or school authorities, this is a severe transgression of “following their statutes” (Uvechukoteihem Lo Telechu). In the Jewish community of Frankfurt, at the school established by Rabbi Samson Raphael Hirsch zt”l (where I personally taught for two and a half years), the students would sit with uncovered heads during general studies but would cover their heads for Torah studies. This was the custom in the Hamburg school as well, based on the rulings of Rabbi Hirsch.
When I first visited Rabbi Hirsch’s home wearing a hat, he informed me that the custom there was to remove one’s hat as a sign of respect when entering the home of a prominent individual. If another teacher at the school saw me refusing to remove my hat before the principal, it might be perceived as disrespect. In cases like this, there is no issue of “following their statutes.”
Therefore, in the case at hand, if the judge allows one to cover their head while taking an oath, that is certainly preferable. Ideally, one should ask the judge for permission, explaining that covering the head is a religious requirement for anything involving sanctity, and an oath is unquestionably a matter of sanctity. However, if the judge refuses to permit it, there is no obligation to incur financial loss over this, and one may swear with an uncovered head if necessary. This is also the ruling of the Mahari Weil in Siman 203. See She’elot U’Teshuvot Yeriot Shlomo, Vol. 1, and Bechor Shor on Shabbat 118b, which discusses cases where the act does not appear to be for the sake of “following their statutes.” See also She’elot U’Teshuvot Chaim Sha’al, Vol. 2, Siman 35, which deals with reciting a blessing with an uncovered head and discusses wearing a wig in this context. The Mahari Weil in Siman 203 also permits taking an oath with an uncovered head, but I would need to examine the text there further.
Also of interest is this Hakirah article “Yarmulke: A Historic Cover-up?”: https://www.hakirah.org/Vol%204%20Rabinowitz.pdf