Would it be permitted for one to enter the Bais Hamikdash carrying a weapon (for example, a gun)? Would it make a difference if it were open vs. concealed carry?
1] There are several passages in Nakh that indicate that weapons were indeed present in the Miqdash.
2 Kings 11:10
ויתן הכהן לשרי המאיות [המאות] את החנית ואת השלטים אשר למלך דוד אשר בבית ה
And the priest delivered to the captains over hundreds the spear and shields that had been king David's, which were in the house of the LORD.
and 2 Chronicles 23:9
ויתן יהוידע הכהן לשרי המאות את החניתים ואת המגנות ואת השלטים אשר למלך דויד אשר בית האלהים
And Jehoiada the priest delivered to the captains of hundreds the spears, and bucklers, and shields, that had been king David's, which were in the house of God.
both openly indicate that King David stored hundreds of spears and shields in the Beth ha-Miqdash. There are no sources to my knowledge that condemn this. This would indicate similarly that the presence of a weapon on Har ha-Bayith (the Temple Mount) is either not an offense against Mora Miqdash (the commanded reverence for the Temple), or that the security needs of the site supersede it.
2] R. Yehudah Leon Templo in his Tabhnith Hekhal lists various chambers of the Temple complex whose precise location is unknown. One of the chambers was the לשכת המגינים (defenses chamber). He describes it as follows:
לשכה נודעת היתה שם בתוך הלשכות הנזכרות אשר שמה נתן דוד המלך במשמר את כלי המלחמה הרבה מאוד להגין על המקדש לעת הצורך מפני אויב ומתנקם ועל כן הלשכה הזאת היתה נקראת לשכת המגינים
There is a chamber that is known of among the aforementioned chambers that King David designated to guard a great magnitude of weapons to protect the Temple in a time of need against its enemies and its vengeful, accordingly it was called lishkath hamaginim
3] Josephus (though non-canonical and not a source of halakhah) corroborates this (Antiquities of the Jews, Book 9, ch. 7):
Jehoiada also opened that armory which David had made in the temple, and distributed to the captains of hundreds, as also to the Priests, and Levites, all the spears and quivers, and what kind of weapons soever it contained; and set them armed in a circle round about the temple, so as to touch one another's hands: and by that means excluding those from entering that ought not to enter.
Here Josephus attests that King David had established an armory (presumably the same לשכת המגינים that R. Templo refers to above) within the Temple and that it stored all kinds of weapons.
4] I believe that Shababnik's inference is incorrect.
The miswa of mora miqdash (reverence for the Temple) establishes a code of conduct that regulates behavior and dress on the Temple Mount. Indeed, items such as a staff (which is functionally a weapon) is generally prohibited to be carried thereon. However it cannot be extrapolated therefrom that weapons per se would have been considered an offense under mora miqdash. We know that there were exceptions.
There is a miswah d'oraitha to guard the Miqdash (Sefer ha-Miswoth, Negative Commandment 67). This task of shemirath hamiqdash (guarding the Temple) was performed by Kohanim/Lewiim who were stationed at 24 different stations throughout the complex. If during the night-watch, a guard was caught sleeping by the chief officer, then the guard would be struck with his staff (חובטו במקלו). See H. Beth ha-Behira 8:10.
This indicates that an exception to the general rule against carrying a staff on the Temple Mount was in place, in order to facilitate the miswah of guarding the Temple. We see from this that the needs of shemirath ha-miqdash supercede those of mora miqdash.
This all seems to indicate, that indeed weapons were permitted in the Miqdash.
As for who was permitted to carry said weapons, there may have been a practical distinction to be made between the average pilgrim on the one hand and the Lewiim/Kohanim/officers/soldiers on the other. I have not however seen any source explicitly make this distinction (but I'll keep digging).
As for what regulations will be in place in the future Temple (guns, concealed carry, etc.) that would be purely speculative. One presumes however that our leaders will attempt to balance tradition with contemporary security and social conditions.
The gemara in brachot 62b relates:
דְּתַנְיָא לֹא יִכָּנֵס אָדָם לְהַר הַבַּיִת לֹא בְּמַקְלוֹ שֶׁבְּיָדוֹ, וְלֹא בְּמִנְעָלוֹ שֶׁבְּרַגְלוֹ, וְלֹא בְּמָעוֹת הַצְּרוּרִים לוֹ בִּסְדִינוֹ, וּבְפוּנְדָּתוֹ מוּפְשֶׁלֶת לַאֲחוֹרָיו, וְלֹא יַעֲשֶׂנָּה קַפֶּנְדַּרְיָא. וּרְקִיקָה מִקַּל וָחוֹמֶר מִמִּנְעָל: וּמָה מִנְעָל, שֶׁאֵין בּוֹ דֶּרֶךְ בִּזָּיוֹן, אָמְרָה תּוֹרָה: ״שַׁל נְעָלֶיךָ מֵעַל רַגְלֶיךָ״. רְקִיקָה, שֶׁהִיא דֶּרֶךְ בִּזָּיוֹן — לֹא כׇּל שֶׁכֵּן?! As it was taught in a baraita: One may neither enter the Temple Mount with his staff in his hand, nor with his shoes on his feet, nor with money tied in his cloth and with his money-belt slung behind him, nor should one make it a shortcut. All the more so, spitting is prohibited a fortiori from the halakha with regard to wearing a shoe. Just as with regard to a shoe, which is generally not considered contemptuous, the Torah said: “Put off your shoes from off your feet, for the place upon which you stand is holy ground” (Exodus 3:5), all the more so spitting, which is considered contemptuous, should be prohibited.
One might infer from this gemara that guns which are not the nicest objects shouldn't be allowed in to the makom hamikdash. Not sure what the idf does nowadays.