In which countries can a government/president violate individual
rights (e.g., imprison or execute an innocent person) in the interests
of state/nation? Are there any states, where a possibility or
illegality of such an action is explicitly inscribed in the
law/constitution?
This is an unhelpful way to frame the question.
In U.S. law, for example, almost no individual rights are absolute.
Your right to free exercise of religion ends when you decide you want to involuntarily use him as a human sacrifice in your religious ritual. Your right to free speech doesn't allow you to defraud someone in the sale of a home. Your right to not be executed without due process doesn't extend to military force authorized by Congress and conducted pursuant the rules of engagement set by the chain of authority from the President on down (this is the Anwar al-Awlaki, case). Your right not to be deprived of property without just compensation doesn't extend to things that you aren't allowed to own like slaves or cocaine or nuclear warheads, and doesn't mean that you have a right to be free of taxes on your property. Your right to vote is conditioned on you bothering to show up to the polls or cast a mail-in ballot by election day. Your right to liberty (if you don't violate the law) is subordinate to the government's right to quarantine you to prevent the spread of a deadly disease.
Sometimes the government does things that it isn't supposed to do, because life isn't perfect.
A police officer executes a no knock warrant at the wrong address, which the executing officer may have had no way to know was wrong, and it causes harm or death. You are arrested and detained prior to trial because there is evidence pointing to your guilt of a crime, but you didn't actually do it. The guy driving a postal van didn't get any sleep the night before because his baby was crying all night, doesn't pay attention, and crashes into a pedestrian causing serious harm. A cop loses his temper and beats the shit out of you because you insulted him even though it was illegal to do so.
The law in those cases decides what remedy, if any, you are entitled to when the government screws up.
If you are innocent but prosecuted in good faith based upon plausible evidence, you don't get anything and have to suffer for the good of society. If the postal van crash broke your legal, you are entitled to money damages from the government and the driver. If the cop loses his temper and unlawfully beats you up, you are entitled to compensatory economic damages like medical costs and lost wages, non-economic damages for pain and suffering, punitive damages, interest, court costs, and attorney fees, but you don't have a right to have the bad cop removed from the police force.
Immunity from liability mostly fits in the category of finding an appropriate remedy even if it sometimes means there is no remedy.
Someone has done something wrong, but for public policy reasons, punishing the person who did it is not the remedy that is available. Presidential immunity is a hard pill to swallow, but it makes lots of sense in the case of judicial immunity. If a judge screws up, you can appeal the judge's decision but you can't sue the judge, because the job is challenging enough that all judges make mistakes sometimes and you couldn't find someone willing to serve if they could be sued every time they got a legal issue wrong.
There are diehards, like the late Justice Scalia, who took the position that even if you could unequivocally prove that you were innocent after key deadlines had passed, that if you were sentenced to death in a case where all your legal rights were respected, that you should be executed. Most judges and legal scholars don't agree, but it is a position taken by someone who had a say in thousands of legal decisions that are the absolute law of the land in the U.S. and many judges do agree with him.
Some countries, like Canada, allow parliament to specifically say that they are going to intentionally violate most of your individual rights (there are some exceptions and conditions) notwithstanding the fact that they are protected by its Charter of Rights and Freedoms, so long as parliament is willing to admit that this is what it is doing.
In sum, it is perfectly normal for some individual rights to yield to greater concerns, or to make it illegal for government to do something but to limit what remedies you have if it does. Some countries go further even than that.