Proudly affixing a mezuzah on a doorpost is a very public religious sign that can cause resentment and even peril under anti-Semitic regimes. I know very little about the level of risk in your case, and so I cannot advise you. But I can give some general guidelines about the question: “Must a mitzvah be fulfilled if it could invite dangerous repercussions?”
A little background is needed in order to address this question. In general, a person is not required to risk his life in order to avoid transgressing a Torah prohibition, except for the sins of idolatry, sexual immorality and murder. Nevertheless, in times of religious persecution, one must be ready to give up his life to avoid even minor transgression.
However, Shulchan Aruch rules that this readiness only applies to one being forced to violate a transgression and not to one threatened by a decree against the performance of positive mitzvot like mezuzah and tefillin. This means that a person would not be obligated to endanger himself by affixing a mezuzah in a time of persecution. In fact, in most cases one would be forbidden to risk his life for the performance of a positive mitzvah, unless he judges that there was a need for him to do so in an extraordinary circumstance.[1] As an example of this exceptional act of self-sacrifice, the Talmud relates the story of a great tzaddik named Elisha:
The wicked state [Rome] once proclaimed a decree against Israel that whoever donned tefillin should have his brains pierced through; yet Elisha put them on and went out into the streets. A Roman soldier saw him; he fled before him, and the latter gave pursuit. As he overtook him, he [Elisha] removed them from his head and held them in his hand, “What is that in your hand?” he demanded. “The wings of a dove,” was his reply. He stretched out his hand and the wings of a dove were found therein.[2]
During the Spanish Inquisition, it is well known that thousands of conversos, Jews who had feigned conversion to Catholicism, continued to practice Judaism in secret. Many of them concealed their mezuzot in ingenious ways at great risk. They also kept the ancient custom, still practiced today, of being careful to sweep the dirt of their doorsteps away from the doorpost concealing the mezuzah.[3] One poignant story of faith and devotion from this period has been recorded for posterity:
It is well known that in Spain during the Inquisition, when they checked and found one of the Conversos who swept dirt to the side away from the mezuzah, they reported that he was still keeping the Jewish religion, and he was martyred “al Kiddush Hashem” — in sanctification of the Divine Name.[4]
But these were acts of extraordinary devotion in extraordinary times. In your case, if you are concerned for real danger, you would not be obligated to put your life and the lives of your family at risk by displaying a mezuzah publicly, especially if you have the option of placing it on the doorpost behind the door. [Regarding this option see question “Danger of Theft,” that a blessing should not be recited.]
[1] Shulchan Aruch Y.D. 157:1.
[2] Shabbos 130a.
[3] Kitzur Shela, cited in Agur B’ohalecha 32:77.
[4] Mezuzas Melachim 18, Ta’am Hatzvi 9, p. 66. Agur B’ohalecha (32:77:195) infers from this story that the custom would apply even if the mezuzah is covered.