I'll add some more perspectives to the answers already given here.
I've found that a few people have discussed the matter from a halachic perspective:
Rabbi Shlomo Goren wrote an essay on the subject, called "The Heroism of Metzada in Light of the Halacha". The essay appeared in a few places, including his book Torat Hashabbat V'hamo'ed, pg. 391-404. In the essay, he wished to compare the case of Metzada with the death of Shaul in battle. He explains that there's a midrash that shows that what Shaul did (committing suicide in battle) was acceptable per halacha:
"שמואל נתנבא בחייו ולאחר מיתתו שאמר שמואל לשאול אם אתה שומע לעצתי ליפול בחרב תהא מיתתך כפרה עליך ויהא גורלך עמי במקום שאני שרוי שם, ושמע שאול לעצתו ונהרג הוא ובניו עמו שיהא חלקו עם שמואל הנביא שנאמר עמי עמי במחיצתי."
"Shmuel prophesied during his life and after his death, as Shmuel said to Shaul: If you listen to my advice to fall by the sword, your death will be an atonement for your and your lot will be with me in the place that I dwell at, and Shaul took his advice and he was killed and his sons with him, for his lot to be with Shmuel the Prophet as it says "with me", with me - near me." (Yalkut Shimoni on Nach 141:1)
He interprets this midrash to mean that it was none other than Shmuel himself who told Shaul that he should die by falling upon his own sword. Rabbi Goren continues and brings other midrashic sources that show that Shaul's death was considered heroic and not sinful: Beresheet Rabbah 34:13, Yevamot 78b, Pirkei D'Rabbi Eliezer 17:13. He continues on with later poskim, some agreeing with Shaul did and others not. He then brings the Tosfot on Avodah Zara 18a that says that if there's a fear that non-Jewish captors will torture those captured, then it's permissible to commit suicide and it's considered a kiddush Hashem. Rabbi Goren continues on, but eventually concludes that as there was a fear among the people of Metzada of being tortured, as evident from Elazar ben Yair's speech, it was incumbent upon them to die a heroic death rather than be captured.
Two people (that I'm aware of) wrote critical replies to Rabbi Goren's conclusion:
The first, Rabbi Levi Yitzchak Rabinowitz, wrote an essay called "The Suicide of the Zealots in Metzada", Sinai 55, pg. 329-332. He points out two things: a. While when there's a fear of torture, it may be permissible to commit suicide, Elazar ben Yair himself announces that the zealots do not fear torture and death, so that wasn't their reasoning for commiting suicide, nor can that be used as a heter for their actions. b. That though what the zealots did in Metzada was per halacha, it wasn't per our halacha. Rather, it was per the halacha of the zealot sect, which, according to Josephus, had branched off from the Pharisees decades, over a century before the destruction of the Temple (Antiquities 18:1:1) and they differed in philosophy from the Pharisees. In what way? Josephus says that they differed on only one point:
"These men agree in all other things with the Pharisaic notions; but they have an inviolable attachment to liberty, and say that God is to be their only Ruler and Lord. They also do not value dying any kinds of death, nor indeed do they heed the deaths of their relations and friends, nor can any such fear make them call any man lord." (ibid. 1:4)
Therefore, when Elazar ben Yair spoke to his men about not being forced into servitude by the Romans, for they have only one master - Hashem - he was simply expressing the zealot philosophy as put forth by the founder of the zealots, Yehudah the Galilean. The zealots believed that it was a sin to serve a human master.1
So what did the Pharisees think about this matter? Rabbi Rabinowitz brings the gemara in Kiddushin 22b:
"Rabban Yoḥanan ben Zakkai would expound this verse as a type of decorative wreath [ḥomer], i.e., as an allegory: Why is the ear different from all the other limbs in the body, as the ear alone is pierced? The Holy One, Blessed be He, said: This ear heard My voice on Mount Sinai when I said: “For to Me the children of Israel are slaves” (Leviticus 25:55), which indicates: And they should not be slaves to slaves. And yet this man went and willingly acquired a master for himself. Therefore, let this ear be pierced."
and notes that the version of the Tosefta says:
"...and crowned upon itself the burden of flesh and blood..."
While these prove that the Pharisees were not welcoming of foreign rule, like the zealots, they did not agree that one must commit suicide because of such a danger. This is evident from the famous story about Rabban Yochanan ben Zakai, who himself went and struck a deal with the Romans that allowed him and other sages to escape the destruction, in order to save Judaism. Rabbi Rabinowitz points out that this was the way of the Pharisees for generations: to prefer the peaceful approach: Shma'ayah and Avtaliyon, Hillel, Rabban Yochanan ben Zakai and his student Rabbi Yehoshua ben Chananyah. While the Pharisees preferred their ideal of being ruled only by Hashem, they were willing to accept foreign rule in certain cases - "give me Yavneh and its sages" - meaning, if Judaism could still carry on.
Therefore, we see that the zealots were acting through zealot rulings, not Pharisaic/Orthodox rulings.
The second person was Rabbi Moshe Tzvi Neriya who wrote an essay that was published in a few places, among them in his book "Tznif Melucha", pg. 196-198, and a slightly revised version in his book "Yisrael B'medinato". In the original version, he points out that Rabbi Goren's understanding of the Yalkut Shimoni on Shmuel telling Shaul to die is problematic, since according to Rabbi Goren, Shmuel literally commanded Shaul to kill himself by his own sword, when this is not evident anywhere in Shmuel's words. He then points out that even if this is the proper understanding of the midrash, then this actually goes entirely against Rabbi Goren's conclusion, because this means that what Shmuel told Shaul to do was per prophecy - a hora'at sha'ah, a temporary, one-time ruling, only for Shaul. Therefore, one cannot compare Shaul to any other case! He then brings various poskim who discussed the case of Shaul and showed how they agreed that what Shaul did was wrong.
He concludes by saying that though the story of Metzada demands further investigation to understand whether they were justified in any way, they most certainly were not justified by Elazar ben Yair who held that "Let us pity ourselves, our children, and our wives while it is in our own power to show pity to them; for we were born to die, as well as those were whom we have begotten; nor is it in the power of the most happy of our race to avoid it" and "This it is that our laws command us to do; this it is that our wives and children crave at our hands; nay, God himself hath brought this necessity upon us". Rabbi Neriya wrote that it is unnecessary to note that no such law exists in the Torah; the Torah wishes we continue on living.
In the revised version, he noted that there's much evidence that has surfaced showing that there's a very good chance that the story of Metzada never happened, which makes discussion of the subject highly hypothetical.
1 Prof. David Flusser in his essay "The Victims of Metzada In Their Eyes and In the Eyes of Their Generation", in the book "Jews and Judaism in the Second Temple Era", pg. 116-146 discusses a view expressed by some, that the midrash in Sifrei Devarim 32:23 refers to the people of Metzada (see here). He points out that even if that's true, it's still unclear from the midrash itself what Chazal thought about the event, whether they viewed it positively or negatively. He discusses the view of this type of martyrdom during the Second Temple Era at length. One piece of evidence that he brings is the midrash from Yalkut Shimoni that Rabbi Goren brought. He analyzes it and concludes that it's an ancient midrash from circa the destruction of the Temple. However, he reaches the same conclusion as Rabbi Rabinowitz, that though both the sages and the zealots shared preference for liberty, they disagreed upon what must one do or not do when there's danger of losing that liberty.