Before I can address your main question, I need to explore your premise further, as the way it's presented is either false or misleading. Before I can do that, I need to discuss a different Gemara on the topic.
Dispute regarding when one gives up his life
Sanhedrin 74a cites a dispute between R' Yishmael and R' Yochanan (quoting R' Shimon ben Yehotzadak and supported by R' Eliezer) regarding when one is obligated to give up his life.
- R' Yochanan's opinion is the one you cite in your first line, that one is obligated to give up his life for idolatry, adultery, and murder always, and all other sins only when either the threat is one of religious persecution or if at least ten Jews are watching.
- R' Yishmael's opinion is that one is not obligated to give up his life if threatened even for idolatry in private, while one is obligated to give up his life if threatened in public.
Tosfos in Avodah Zarah
Tosfos to the cited Gemara in Avodah Zarah start off by assuming that when Rava differentiates in a case of idolatry between sinning in private and sinning in public, he is paskening the halacha like R' Yishmael:
לכאורה משמע דרבא ס"ל דאונס דצנעא אין לו למסור עצמו ומתוך כך היה נראה לפסוק כרבי ישמעאל דשרי נמי עבודת כוכבים בצנעא
They reject this premise on two grounds:
- For whatever reason, they find it impossible to presume that there is any case of idolatry which is permissible.
- They quote R' Achai Gaon in his She'iltos to Parshas Va'eira who explicitly paskens like R' Yochanan.
וקשיא דחס ושלום שנפסוק עבודת כוכבים יעבור ואל יהרג ועוד בשאלתות דרב אחאי פרשת וארא (סימן מב) פוסק כר' יוחנן דאמר בשילהי בן סורר ומורה (סנהדרין דף עד. ע"ש) משום ר"ש בן יהוצדק כל מצות שבתורה יעבור ואל יהרג חוץ מעבודת כוכבים וגלוי עריות ושפיכות דמים יכול אפילו בפרהסיא ת"ל ולא תחללו את שם קדשי
Therefore, they assume that Rava in principle holds of R' Yochanan, bringing several proofs to this point. In the cited Gemara in Avodah Zarah, they say, Rava's explaining that the Braisa works even according to R' Yishmael:
לכך נראה דרבא נמי אית ליה דרבי יוחנן והא דקא משני לתרוצי הברייתא אפילו אליבא דר' ישמעאל הוא דאתא וכן משמע נמי בפ"ב דכתובות (דף יט.) דרבא אית ליה דרבי יוחנן דא"ל רבא אילו אתו לקמן לאימלוכי אמרי' להו זילו חתומו וכו' דאמר מר אין לך דבר שעומד בפני פיקוח נפש אלא עבודת כוכבים וגלוי עריות ושפיכות דמים והתם נמי בצנעא מיירי דאין דרך שיאנס אותם בפני י'
As an alternative answer, they cite "my beloved Rabbi, R' Moshe of Kotzi, in his Sefer HaMitzvos which he compiled" who explains that Rava's statement in Avodah Zarah does not contradict R' Yochanan's position. What Rava means here is that there are two separate obligations involved: don't worship idolatry, and serve Hashem even if it comes to giving up your life. Neither the former prohibition, nor its punishment, apply if one was forced in private to worship an idol. The latter obligation would still apply, and one would still have to give up his life; nevertheless, this obligation is not punishable by the death penalty.
It therefore comes out that there's no contradiction between the two Gemaras; they're merely addressing two different requirements. Rava still holds of R' Yochanan, and therefore we pasken accordingly, as recorded by Rav Achai Gaon.
כתב בסוף פרק בן סורר ומורה וז"ל רבא דפ' ר' ישמעאל לא פליג עליה דר' יוחנן אלא ה"פ אמר רבא הכל היו בכלל לא תעבדם בין לאזהרה בין למיתה כשהוא אומר וחי בהם יצא אונס דצנעא מכל וכל בין מאזהרה בין ממיתה אבל הא מודי רבא דאיכא עשה דבכל נפשך שיש למסור עצמו אפילו בכל אונסא כדאמר ר"א בברייתא כשהוא אומר לא תחללו אהדריה בכלליה והיינו אונס דפרהסיא בין לאזהרה בין למיתה והואיל ורבא שהוא בתרא לא פליג עליה דרבי יוחנן שריר וקיים פסק השאלתות שיש לאדם למסור עצמו למיתה ואפילו באונס ובצנעא עכ"ל
How does this extend to murder and immorality?
The Rambam paskens like Tosfos' second answer in Hil. Yesodei HaTorah 5:4 (though he chooses a different source than Tosfos), and he explicitly extends it to cases other than idolatry.
וְכָל מִי שֶׁנֶּאֱמַר בּוֹ יֵהָרֵג וְאַל יַעֲבֹר וְעָבַר וְלֹא נֶהֱרַג הֲרֵי זֶה מְחַלֵּל אֶת הַשֵּׁם. וְאִם הָיָה בַּעֲשָׂרָה מִיִּשְׂרָאֵל הֲרֵי זֶה חִלֵּל אֶת הַשֵּׁם בָּרַבִּים וּבִטֵּל מִצְוַת עֲשֵׂה שֶׁהִיא קִדּוּשׁ הַשֵּׁם וְעָבַר עַל מִצְוַת לֹא תַּעֲשֶׂה שֶׁהִיא חִלּוּל הַשֵּׁם. וְאַף עַל פִּי כֵן מִפְּנֵי שֶׁעָבַר בְּאֹנֶס אֵין מַלְקִין אוֹתוֹ וְאֵין צָרִיךְ לוֹמַר שֶׁאֵין מְמִיתִין אוֹתוֹ בֵּית דִּין אֲפִלּוּ הָרַג בְּאֹנֶס. שֶׁאֵין מַלְקִין וּמְמִיתִין אֶלָּא לְעוֹבֵר בִּרְצוֹנוֹ וּבְעֵדִים וְהַתְרָאָה שֶׁנֶּאֱמַר בְּנוֹתֵן מִזַּרְעוֹ לַמּלֶךְ (ויקרא כ ה) "וְשַׂמְתִּי אֲנִי אֶת פָּנַי בָּאִישׁ הַהוּא". מִפִּי הַשְּׁמוּעָה לָמְדוּ הַהוּא לֹא אָנוּס וְלֹא שׁוֹגֵג וְלֹא מֻטְעֶה. וּמָה אִם עֲבוֹדַת כּוֹכָבִים שֶׁהִיא חֲמוּרָה מִן הַכּל הָעוֹבֵד אוֹתָהּ בְּאֹנֶס אֵינוֹ חַיָּב כָּרֵת וְאֵין צָרִיךְ לוֹמַר מִיתַת בֵּית דִּין. קַל וָחֹמֶר לִשְׁאָר מִצְוֹת הָאֲמוּרוֹת בַּתּוֹרָה.
And anyone about whom it is said that he should he killed and not violate, and he violates and is not killed - this is a desecration of the Name. If it was amongst ten Jews - this is a public desecration of the Name. He has nullified the positive commandment to sanctify His Name and violated the negative commandment not to desecrate it. Nevertheless, since he violated it under duress, we don't give him lashes, and it goes without saying that we don't kill him in court, even if he murdered under duress. As it says regarding one who gives his children to Molech (Vayikra 20:5): "And I will place My face against that man." From tradition we learn: "That [man]," and not one who was forced, did so by mistake, or did so by accident. If by idolatry, which is more severe than anything else, one who worships it under duress does not receive Kares, and it goes without saying [he doesn't receive] death in court, all the more so to all other prohibitions in the Torah.
Summary
The Gemara in Avodah Zara 54 seems to imply that in private one is allowed to worship an idol while under compulsion and live.
According to Tosfos' first answer, that's technically correct, but Rava's playing devil's advocate and doesn't actually hold of what he says here. According to their second answer, that's mostly correct: one can live after doing so, but that doesn't make it permissible.
Is this true regarding the other two in private?
According to the Rambam, who paskens according to Tosfos' second answer: Yes.