Shulchan Aruch: All of the transgressions which are in the Torah, with the exception of idolatry, sexual prohibitions, and murder: If someone is told to transgress them or he will be killed, so long as he is in private, he should transgress and not be killed. If he wants to be stringent upon himself and be killed, he may do so if the idolater intends to make him violate his religion. Rama: If he can save himself with all he has, he must give it all rather than transgress one of the negative commandments (Ran in Sukkah, Perek Lulav haGazul, and Rashba and Raavad and Rivash Siman 387). When they [Chazal] said that anyone who has the ability to protest and does not, he is seized in the same sin - here, where there is a chance of danger, he does not need to give up his money over this (Mahariv Siman 156). Shulchan Aruch: If he is in public - that is, in front of ten Jews - he must allow himself to be killed rather than transgress, providing the idolater intends to make him violate his religion (even if this is over a minhag such as the way one ties one’s shoes) (Beis Yosef). But if he [the idolater] intends only for his own benefit, he [the Jew] should transgress rather than be killed. If, however, it is a time of legislation (only against Jews) (Beis Yosef in the name of the Nimukei Yosef), even about the strap of one’s shoes he should be killed rather than transgress. Rama: And this is only if they wish to make him violate a negative commandment; if they made a law that one should not fulfill positive commandments, however, he does not need to fulfill it if he will be killed (Ran Shabbos Perek BaMeh Tomnin and Nimukei Yosef Sanhedrin Perek Sorer uMoreh). Nonetheless, if the hour requires it and he wishes to fulfill it and be killed, he may do so (Maharik Shoresh 88). Shulchan Aruch: And by idolatry, sexual prohibitions, and murder, even in private and not a time with legislation and even if the idolater intends it only for his own benefit, he must be killed rather than transgress. Rama: And this is only when they tell him to do an action: for instance, if they tell a man to transgress a sexual prohibition or he will be killed. If they force a woman to have sex or throw him over a child to murder it or he is already erect and they force him to have forbidden sex, he need not be killed (Beis Yosef in the name of Tosfos and Ran Psachim Perek Kol Sha’ah). All prohibitions of idolatry and sexuality and murder - even if they are not punishable by death, just prohibitions without explicit punishment - he must be killed rather than transgress. On the prohibition of “Do not put a stumbling block before the blind” he may transgress rather than be killed (Ran Psachim Perek Kol Sha’ah and Sanhedrin Perek Ben Sorer uMoreh). An idolater sleeping with a Jewish woman is not included as a sexual prohibition (Beis Yosef in the name of the Ramban and the authorities cited above). Idolaters who told a Jew, “Give us one of you so we may kill him” - they may not give him over unless they [the idolaters] singled him out and said, “Give us Ploni” (Mishnah Trumos 8, Rambam Yesodei haTorah 5). There are those who say that even in this case, one should not give him over unless he is already liable for death like Sheva ben Bichri (Beis Yosef in the name of Rashi and the Ran). Likewise, women who were told by idolaters, “Give us one of you so we may rape [lit. make impure] her” - they must all be raped rather than hand over one Jewish life (Rambam ibid). Any place where it is said, “Be killed rather than transgress,” if he transgressed and was not killed, even though he has desanctified the Name, nonetheless he is considered forced and is not liable. This is only where he could not have fled - if he could have fled, and did not do so, he is like a dog sitting on his vomit and is considered to have transgressed deliberately (Beis Yosef in the name of the Rambam Yesodei haTorah 5).
Shulchan Aruch: It is forbidden for a man to claim that he is an idolater so that they will not kill him; if, however, so that they will not know he is a Jew, he changes his clothes during a time of legislation, this is permitted, since he does not say that he is an idolater. Rama: Even if he must wear shaatnez (Nimukei Yosef Bava Kama Perek haGozel (the second one)). Even though it is forbidden to say that he is an idolater, nonetheless he may say things that can be interpreted multiple ways (Nimukei Yosef Bava Kama Perek haGozel) and the idolaters will understand that he has said that he is an idolater while he means something else. Likewise, if he can trick them so that they will think he is an idolater, this is permitted (Trumas HaDeshen Siman 197). In the same vein, one who desires another man’s wife - if his wife can sleep with him such that he will believe he is sleeping with the forbidden woman, this is permitted (ibid in the Nimukei Yosef). All of this is permitted only where there is a danger, but where there is no danger - for instance, he wears idolaters’ clothes so they will not recognize that he is a Jew so that he can avoid the tax or suchlike - that is forbidden (Hagahos Ashiri and Nimukei Yosef Bava Kama Perek haGozel (the second) and Trumas haDeshen Siman 196 and other authorities).
Shulchan Aruch: One who is liable for the death penalty may run to an idolatrous house of worship to save himself (some say that at a time of legislation this is prohibited (Kol Bo). See above Siman 150).