The core ruling on wearing two hats one atop the other is attributed to the Rema, and Igros Moshe OC 1:108 cites him as permitting this, while drawing a distinction between hats—worn customarily for adornment or warmth—and two belts, which are not treated the same way.
Igros Moshe OC 1:107 qualifies this permission sharply: the Rema's leniency applies only to a particular arrangement where the larger hat covers part of the head left exposed by the smaller one underneath, and otherwise the implication runs toward prohibition, distinguishing this from the broader formulation sometimes attributed to the Rema.
Igros Moshe OC 1:109 develops the operative distinction further: a cover placed over a hard hat merely to keep off rain is forbidden when it is not a genuine garment and does not add meaningful coverage, whereas a second hat is permitted when it functions as an actual garment—providing warmth, broader coverage, or conforming to the ordinary way people dress.
Igros Moshe OC 1:110 states the general principle underlying these rulings: multiple garments or head coverings worn in the customary manner may constitute genuine clothing and are permitted, while additional coverings worn only to prevent dirt, without providing warmth, are treated merely as a burden and are prohibited.
A related case appears in Responsa Maharashdam, Orach Chayim 4, which takes up the question of a felt hat worn over a turban to protect against rain, and reasons that even though it is worn only during rain to prevent soiling, this does not make it a forbidden burden, since the reasoning that would forbid it as such does not hold.
The underlying laws of head covering during prayer and brachos are set out in Shulchan Arukh, Orach Chayim 91:3-4, which records the view that pronouncing God's name with an uncovered head is forbidden and that straw-woven hats count as a covering while merely placing a hand on the head does not, and in Mishnah Berurah 91:12 and Arukh HaShulchan, Orach Chayim 91:5-6, which elaborate that one must wear a proper hat as worn in the street rather than only a small cap underneath, and that uncovering the head before dignitaries or in prayer is improper regardless of local custom. Kaf HaChayim on Shulchan Arukh, Orach Chayim 91:18-20 adds that even straw-woven coverings, though technically valid, should be avoided where they might be mistaken for exposed hair, out of concern for appearances in prayer and brachah.
Kitzur Shulchan Arukh Yalkut Yosef, Orach Chaim 91:7 rules that during the Shemoneh Esrei of Mincha, Shema, and Maariv, and likewise at Birkat HaMazon, one should not remove the hat and rely on a skullcap alone, since doing so appears as insolence toward Heaven, and one should instead pray wearing the proper hat as well as the skullcap beneath it—language that itself assumes a case of two head coverings worn together as the normative practice.
A separate thread concerns women's head covering: Igros Moshe EH 1:58 argues that the prohibition against uncovered hair pertains to the head generally and does not necessarily forbid exposing less than a tefach, and explicitly rejects the claim that women are obligated to wear two head coverings simultaneously, while maintaining that greater covering is praiseworthy though not required to avoid being deemed in violation of Dat Yehudit. Maayan Omer 9:2:40 takes up a related point, holding that a hand placed over the head can be an effective covering in that context, distinguishing it from the law of a man's uncovered head during prayer where such a covering is ineffective.
Two further sources touch on double coverings in a different context, tefillin rather than hats: Shut HaRav HaRashi 4:17 states that there is no practice of placing a protective cover on the head-tefillin as is customary for the hand-tefillin, and Responsa Rav Pealim, Volume I, Orach Chayim 4:11-12 discusses the order and manner of donning both tefillin when both are presented together, ruling on which one should be removed and re-placed and whether a second brachah is recited, following the position of the Arizal on the precedence of the hand-tefillin.