Diplomatic immunity and criminal acts As in the case of the 23rd July 2017 incident in which an Israeli security guard killed 2 Jordanians outside of Israel's embassy to Jordan, if the guard has diplomatic immunity, does that mean he can "kill whomever" and never get prosecuted?
The restrictions on embassy staff are diplomatic and political rather than legal. The Vienna Convention says that a diplomatic agent "shall enjoy immunity from the criminal jurisdiction of the receiving State." (Article 31, including the full stop). It also says that "members of the service staff of a mission who are not nationals of or permanently resident in the receiving State shall enjoy immunity in respect of acts carried out in the course of their duties..." (Art 37). So assuming that the Israeli Ambassador states that the shooting was in the course of the security guard's duties and he does not wish to waive immunity, and that the guard was an Israeli rather than a local hire; yes, the Jordanian authorities can do nothing to this guard, even if he does the same thing tomorrow.
The question has no definitive resolution other than the authorities cited and some other related authorities such as the protocol rules of the Secretary of State for diplomatic purposes and the Presidential succession statute. It has never been litigated any reasonable interpretations of the the constitution and relevant law could be argued. There is also some case law under the appointments clause regarding which departments count as principal departments. There is a broad consensus regarding the existence of 15 principal departments of the United States government and which departments those 15 departments are in practice. I would say that the majority view is that the highest ranking person in each department is the principal officer of that department (which is provided for by statute in the event of vacancies) but there is also an argument that only the Congressional ratified and Presidentially nominated Secretary of a department (and the Attorney General in the Justice Department similarly appointed) count. In the event of a dispute, either Congress or a court could resolve the issue depending upon how the issues ended up being presented for a decision. If asked, the White House Counsel would render a formal opinion that would be binding upon all members of the Executive Branch. Triller novel writer Tom Clancy has explored some of the scenarios as have other writers in the same genre, but since the 25th Amendment has never been invoked in this manner, there is no definitive answer or even a non-judicial precedent to provide us with guidance on the question.
Everyone physically present in the US is protected by the US Federal constitution. (In some cases persons not physically in the US also have protection from the US constitution. When that applies is too complex for this answer.) Most of the rights protected by that constitution are available to anyone present, whether citizen, lawful immigrant, lawful visitor, or a person in the US without lawful authority. A few rights, such as the right to vote and to run for public office, are limited to citizens. If a person was arrested but not informed of his or her Miranda rights, then statements made to the arresting officers (or later interrogating officers) would not be admissible in court, unless an exception to the Miranda rules applies, which is unlikely. I can't say if this happened in the particular case mentioned in the question. In general, in the area of criminal procedure, there is no difference between citizens and others subject to US jurisdiction (accredited foreign diplomats normally have immunity). A few crimes can only be committed by citizens (or others owing allegiance to the US) such as treason. A few crimes, such as unlawful entry to the US, can't be committed by citizens, as citizens automatically have a right to enter. But criminal procedure and constitutional rights affecting criminal procedure, are the same for all in the US, citizen or not. (Oh, there are special laws for minors, but that isn't a matter of citizenship.)
No, each state is a "sovereign" and whenever a statute describes a crime it is always some act committed by a "person" and these two categories are mutually exclusive. See, for example, US Supreme Court in U.S. v. United Mine Workers of America, 330 U.S. 258, 67 SCt 677 (1947): "In common usage, the term `person' does not include the sovereign and statutes employing it will ordinarily not be construed to do so." Repeated by US Supreme Court in Wilson v. Omaha Indian Tribe 442 US 653, 667 (1979): "In common usage, the term 'person' does not include the sovereign, and statutes employing the word are ordinarily construed to exclude it."
I don't believe your premise is necessarily true. As the Supreme Court has held, a defendant can be prosecuted for perjury after being convicted for another offense at trial: The conviction of Williams, at a former trial, for beating certain victims is not former or double jeopardy. Obviously perjury at a former trial is not the same offense as the substantive offense, under 18 U.S.C. § 242, of depriving a person of constitutional rights under color of law. . . . It would be no service to the administration of justice to enlarge the conception of former jeopardy to afford a defendant immunity from prosecution for perjury while giving testimony in his own defense. United States v. Williams, 341 U.S. 58, 62 (1951) (emphasis added). Now as a practical matter, trying a convicted person for perjury is most likely rare, since the prosecutor has already obtained a conviction for the underlying offense. Starting another prosecution for perjury might be excessive or unnecessary. But that doesn't mean it's categorically prohibited. Note also that perjury by the defendant can be considered by the judge to enhance the defendant's sentence. United States v. Dunnigan, 507 U.S. 87, 96 (1993).
Laws that add special penalties to killing a police officer require that the accused knows that the victim is a police officer, for example DC 22-2106 (emphasis mine) (a) Whoever, with deliberate and premeditated malice, and with knowledge or reason to know that the victim is a law enforcement officer or public safety employee, kills any law enforcement officer... A prosecution would need to show beyond a reasonable doubt that the accused knew the victim was an undercover police officer to convict them under this statute. In the case presented, it seems unlikely that the bartender could be convicted under such a statute, even without consideration of a possible self-defense argument.
The law applies equally to everyone The fact that the person misunderstood the law is irrelevant irrespective of the reason for it. That said, in both cases the person would have access to a lawyer and consular assistance who could explain the law to them.
No Even if there were any evidence that any member of the US government were involved (there isn’t), that is a matter for the US justice system. The US is not a member of the International Criminal Court so no Supra-National body has jurisdiction.