Although the meanings of these two words can be similar in some contexts, it is best to think of them as different in meaning. Both words describe the status of a person who is free from negative consequences; however, their similarity ends there.
Immunity is the condition of a person who will not become ill, or feel bad, or suffer legal punishment, due some specific threat:
Anti-vaccination politicians should know they do not have immunity—neither against viruses, nor against lawsuits.
Impunity is the attitude of a person who does not fear punishment or other negative consequences:
Donald Trump believes he can lie with impunity.
While a person with immunity is immune, there is no adjective equivalent for impunity—probably because impunity is only an attitude; a person who acts with impunity may not really be immune from moral or legal consequences.