I think that it certainly would be better to give up your life to not be sacrificed to an idol since there are multiple cases with the cantonists where the Tzemach Tzedek (זצ״ל) told them that it would be better to give up your life al kiddush Hashem than to convert to christianity. You can probably apply that here to.
A possible source for an opinion that Moshe did not sin is a Midrash in Bamidbar Rabbah Parshah 19. While it does not explicitly say that Moshe did not sin, it offers a different reason for his being barred from entering Israel, namely so that people will not say that if Moshe abandoned the people in the wilderness and entered Israel with a new group it must ...
It is definitely not a clear cut picture.
By Aharon the Midrash writes two very insightful points:
In Vayikra Rabbah 20:12 it writes:
אָמַר רַבִּי יוּדָן מִפְּנֵי מָה נִסְמְכָה מִיתַת אַהֲרֹן לִשְׁבִירַת לוּחוֹת, אֶלָּא מְלַמֵּד שֶׁהָיָה קָשֶׁה לִפְנֵי הַקָּדוֹשׁ בָּרוּךְ הוּא מִיתָתוֹ שֶׁל אַהֲרֹן כִּשְׁבִירַת לוּחוֹת.
Rabbi Yudan said: Why ...
Rambam in Hilchot Shegagot 2:2 rules that even if one knew that something was a biblical prohibition, but was unaware that the punishment incurred is karet, it is classified as a shegagah and he brings a chatat.
I surmise that the same would be true in your case of an individual believing the prohibition is rabbinic; it would also be classified as a shegagah ...