Consider this passage from 1st Maccabees, previously discussed here and here:
The king’s officers who were enforcing the apostasy came to the town of Modein to make them offer sacrifice. Many from Israel came to them; and Mattathias and his sons were assembled. Then the king’s officers spoke to Mattathias as follows: “You are a leader, honored and great in this town, and supported by sons and brothers. Now be the first to come and do what the king commands, as all the Gentiles and the people of Judah and those that are left in Jerusalem have done. Then you and your sons will be numbered among the Friends of the king, and you and your sons will be honored with silver and gold and many gifts.”
But Mattathias answered and said in a loud voice: “Even if all the nations that live under the rule of the king obey him, and have chosen to obey his commandments, every one of them abandoning the religion of their ancestors, I and my sons and my brothers will continue to live by the covenant of our ancestors. Far be it from us to desert the law and the ordinances. We will not obey the king’s words by turning aside from our religion to the right hand or to the left.”
As I said earlier, the main thing here is not to say that “our religious beliefs are true,” but fidelity to “the covenant of our ancestors.” We can note also the mention of “the law and the ordinances,” which is not mainly about what is true, but about what should be done.
This idea of fidelity to the ancestors appears to have been a fairly typical attitude of the Jewish people throughout history, perhaps explaining why they managed to remain a fairly coherent people even while deprived of a country for many centuries. This is unusual but not unique.
Maimonides explains the situations in which one should be willing to sacrifice one’s life rather than violate the law:
The entire house of Israel are commanded regarding the sanctification of [God’s] great name, as [Leviticus 22:32] states: “And I shall be sanctified amidst the children of Israel.” Also, they are warned against desecrating [His holy name], as [the above verse] states: “And they shall not desecrate My holy name.”
What is implied? Should a gentile arise and force a Jew to violate one of the Torah‘s commandments at the pain of death, he should violate the commandment rather than be killed, because [Leviticus 18:5] states concerning the mitzvot: “which a man will perform and live by them.” [They were given so that] one may live by them and not die because of them. If a person dies rather than transgress, he is held accountable for his life.
When does the above apply? With regard to other mitzvot, with the exception of the worship of other gods, forbidden sexual relations, and murder. However, with regard to these three sins, if one is ordered: “Transgress one of them or be killed,” one should sacrifice his life rather than transgress.
When does the above apply? When the gentile desires his own personal benefit – for example, he forces a person to build a house or cook food for him on the Sabbath, he rapes a woman, or the like. However, if his intention is solely to have him violate the mitzvot, [the following rules apply:] If he is alone and there are not ten other Jews present, he should transgress and not sacrifice his life. However, if he forces him [to transgress] with the intention that he violate [a mitzvah] in the presence of ten Jews, he should sacrifice his life and not transgress. [This applies] even if [the gentile] intended merely that he violate only one of the [Torah’s] mitzvot.
All the above [distinctions] apply [only in times] other than times of a decree. However, in times of a decree – i.e., when a wicked king like Nebuchadnezzar or his like will arise and issue a decree against the Jews to nullify their faith or one of the mitzvot – one should sacrifice one’s life rather than transgress any of the other mitzvot, whether one is compelled [to transgress] amidst ten [Jews] or one is compelled [to transgress merely] amidst gentiles.
The basic idea is that ordinary situations and in unimportant matters, it is better to violate the law than to be killed, but one must be willing to be killed in order to avoid violating the law in important ways, which Maimonides specifies as “the worship of other gods, forbidden sexual relations, and murder.”
But in two situations, he says, you must be willing to die for any law or custom whatsoever, no matter how small: when a gentile is trying to make you violate the law before other Jews simply for the sake of scandal, or when an oppressor attempts to suppress the Jewish faith, laws or customs.
This would not be understood only to refer to violations of things commanded in Scripture, but to any Jewish custom whatsoever. For example, the Talmud says:
When R. Dimi came, he said: This was taught only if there is no royal decree, but if there is a royal decree, one must incur martyrdom rather than transgress even a minor precept. When Rabin came, he said in R. Johanan’s name: Even without a royal decree, it was only permitted in private; but in public one must be martyred even for a minor precept rather than violate it. What is meant by a ‘minor precept’? — Raba son of R. Isaac said in Rab’s name: Even to change one’s shoe strap.
The example of a “minor precept” is that if the Jews of a certain time and place wear sandals or shoes that differ from those of the gentiles, one must be prepared to suffer martyrdom rather than change even the details of one’s shoes, at least in the two situations discussed above.