Upvote:1
In answer the general question in the title:
No, it is illegal. Yes, it is possible.
If a country as a law forbidding another one's citizens from entering, and you're a citizen of the forbidden country, you're not allowed to enter. It doesn't matter what passport you present when entering.
Of course, when you enter a country they look at your passport, and base their decision on what they see. If you have a passport from a "good" country, you'll be admitted.
However, as I wrote above this is illegal, and if it's found out you'll be in trouble (anywhere between deportation and trial for espionage). For example, if you carry the forbidden country's passport in your luggage, and for some reason it's searched. But there's no database they can search and find your other nationalities.
For an example other than USA-Iran, Israeli citizens are banned from most Muslim countries, yet there are occasionally news stories by Israeli journalists travelling to these countries, with a foreign passport.