PRETENDING TO BE A NOCHRI [Mesiras Nefesh :identity]
Gemara
They carved R. Meir's image on the gates of Romi, and announced that whoever sees him should seize him. One day, he was seen;
Some say that he found food of Nochrim; he dipped fingers in it, and sucked (different) fingers.
His pursuers: Heaven forbid, this is not R. Meir!
Nedarim 62b (Rava): A Chacham may say 'I am a servant of the fire (they will think that he is a priest who serves fire). I will not pay the head-tax'.
This is allowed, for clearly, he says this only to avoid damage.
Bava Kama 113a (Beraisa - R. Shimon): R. Akiva permits wearing Shatnez to evade the tax.
Medrash Rabah (Vayishlach 82:8): Two Talmidim of R. Yehoshua changed their outer garments at the time of Shemad (decrees against Mitzvos). An officer told them 'if you are Bnei Torah, give your lives for it. If not, why should you be killed for it?' They said 'we are Bnei Torah, and we give our lives for it, but it is not normal to kill oneself.'
Rishonim
Rosh (2:4): The Yerushalmi (2:1) says that a woman can hide herself and say that she is a Nochris, but a man cannot (they can see that he is circumcised). Do not say that one may claim to be a Nochri so they will not kill him. Surely, he may not. This is Kofer b'Ikar (denying Torah)! Since they want to kill him if he will not convert to their creed and be an idolater like them, claiming to be a Nochri is admission to their creed and acceptance to serve their idolatry! Rather, the Yerushalmi teaches that Arayos is always a problem (when one is secluded with Nochrim), whether or not she will admit that she is a Yisraelis. It is not clear that a woman is in mortal danger, for she could say that she is a Nochris. However, it is forbidden to do so. R. Eliezer ben Parta (17b) denied that he learned and received Semichah (when he was accused of teaching Torah), but this did not connote that he is a Nochri.
Gra (YD 157:20): This is difficult. Rather, Chachamim in the Yerushalmi argue about whether one may say that he is a Nochri.
Rosh (Bava Kama 10:11): Do not explain that R. Akiva permits evading the tax through wearing Kilayim, i.e. so they will think that he is a Nochri. R. Akiva would not permit this, for it seems that he denies being a Yisrael in order to be exempt from the tax.
Nimukei Yosef (Bava Kama 40a DH Omar): Surely, if Nochrim decreed that a Yisrael must transgress wearing Nochri clothing, he must be Moser Nefesh, even though it is not one of the three Aveiros (idolatry, murder and Arayos that require Mesiras Nefesh). One must be Moser Nefesh even if they decree to wear shoelaces like Nochrim! However, if they decreed to kill anyone who is called a Yehudi because he does not serve idolatry, one may dress like a Nochri to save his life and flee. This is unlike the Isur to be cured from idolatry, or the man who was in mortal danger if he will not have Bi'ah with a certain girl, or at least talk in back of a fence with her. There, he desired the Isur itself. Chachamim were stringent lest he come to Aveirah, or lest Bnos Yisrael be lewd. Here, he merely wants to deceive them. He is pained at the time. Chachamim would not have been stringent to forbid his wife to (pretend to be the girl and) talk with him in back of a fence, even if he intended for Isur. All the more so we permit when he does not want to enjoy the Aveirah, and Piku'ach Nefesh permits the Aveirah. R.Tzadok and Rav Kahana risked their lives to avoid sinning with a Nochris. They would not have done so had they been able to trick her into thinking that they want to comply. One may not be stringent about Piku'ach Nefesh in matters that Chachamim did not specify. Some explain in the name of Tosfos that we permit a Chacham to say 'I am a servant of the fire', for he intends for Hash-m, Who is called "a consuming fire." All the more so, here is permitted! Others explain that there, they think that he means that he is a servant of the priest who serves the fire, or any other idolatry. In any case, they think that he is a Nochri. All the more so here is permitted, for he does not say anything! The Medrash shows that even one who is ready to be Moser Nefesh may change his clothing, for perhaps they will not recognize him and not kill him.
Gra (ibid.): The Medrash teaches that changing clothing helps only if one will not be asked (if he is a Yisrael, but if he is asked, he may not lie).
Sefer Chasidim (199): A Yisrael may not put on an ornament like priests of idolatry. He may change his garments, but he may not shave his beard. Once, at a time of Shemad someone dressed like a Nochri and fled. Chachamim told him that since he planned this, he should have bought Nochri garments and fixed them with stitches not of linen, so he needs atonement (for Shatnez). One who goes in a caravan should have garments like Nochrim without Shatnez. He should not wear Yisrael garments, for this will harm the Rabim. A Chasid went with a group. They told him to wear a cloak so they will not recognize him, but he refused, for it had Shatnez. He was seized, and they needed to redeem him. He struggled to repay those who redeemed him, for he caused it. One who must go on the road should prepare garments of hemp or silk, so it will not be Shatnez.
Sefer Chasidim (201): One may wear Nochri clothes to deceive the enemy, like R. Meir who stuck one finger into Isur and another into his mouth.
Terumas ha'Deshen (196): Sefer Chasidim connotes that one may dress like a Nochri to save his life, even if there is no danger. He learns from R. Meir, who pretended to be a Nochri regarding a full Isur. This is permitted even at a time of Shemad. One must be Moser Nefesh even for shoelaces when they recognize that he is a Yisrael and want to force him to change from the custom of Yisrael. When he disguises himself like a Nochri and they do not recognize him, there is no Chilul. However, there is no proof from R. Meir. Perhaps the Nochrim thought that he is a Yisrael who eats Neveilah! They said 'Heaven forbid, this is not R. Meir!' They did not say 'Heaven forbid, this is not a Yisrael!'
Note: I did not see anyone bring a proof from the fact that R. Meir dressed up like a (Nochri) soldier to test if his sisiter-in-law was still a Tzadekes (18a). Perhaps we may not learn from there, for he got no personal benefit from this, and did so to avoid Chilul Hash-m (lest people think that a Yisrael wanted to hire a harlot). Alternatively, had he not dressed like a Nochri, his sisiter-in-law would have realized that it is him.
Terumas ha'Deshen (ibid.): The Rosh says that one may not learn from the Yerushalmi that one may claim to be a Nochri. In Bava Kama he connotes that it is forbidden. Not only wearing Kilayim is forbidden, rather, even if it is of two or three colors, or has strings and pieces at the bottom and corners (like Nochri clothing), or to go around with a bare head. However, perhaps this is only to evade taxes, but for danger it is permitted, like in Sefer Chasidim. However, if one put himself in the danger, perhaps it is forbidden. Also, perhaps they will discover that he is a Yisrael, and there will be Chilul Hash-m. Perhaps the Halachah follows the opinion in the Yerushalmi that forbids even when there is danger. One must be careful that it does not seem that he admits to idolatry, which is like denial of the entire Torah.
Poskim
Shulchan Aruch (YD 157:2): One may not say that he is a Nochri in order that they will not kill him. However, one may change his clothing at a time of decrees, since he need not say that he is a Nochri.
Rema: He may even wear Shatnez. He may not say that he is a Nochri, but he may say words that can be understood in two ways, and they will think that he says that he is a Nochri, but he intends differently. Similarly, one may deceive them to think that he is a Nochri. This is permitted only at a time of danger, but not in order to evade taxes.
Shach (18): If it were permitted to say (without intent) 'I will accept your creed', also men could save themselves! Heaven forbid (surely this is not the law)! The Rema and Maharshal connote that one may speak deceptively only for danger, but not just to save money. However, we permit this to a Chacham to be exempt from taxes! Maharshal says that this is only for a Chacham, who is exempt from taxes, and Nochrim seek to steal from him. He will not do so in other situations. Also the Rosh (Nedarim 62b DH l'Tzurba) connotes that we permit only a Chacham.
Bach (5): Even if there is no decree, but there is more danger for Yisre'elim, one may dress like a Nochri, but without Kilayim. Maharam MIntz permits (only) in order to find out about decrees that they are plotting against Yisrael. It seems that he forbids only dressing like a Nochri for one's benefit, e.g. to evade taxes, but permits when there is danger. If David was among Nochrim, and other Nochrim asked 'are there Yisre'elim among you' (in order to harm them), and David was ready to admit if he is asked, and one of his group said 'there is no Yisrael with us', if David was quiet he did not sin. He may fast Monday, Thursday and Monday if he is worried about this.
Gra (21): One must be Moser Nefesh for shoelaces when Nochrim make him transgress. Here, they do not recognize him, so there is no Chilul Hash-m.