The country you currently find yourself in can always prosecute and sentence you to the extent provided by local law. That includes the death penalty. Your own country might protest through diplomatic channels but there is no general exemption for foreigners. Treaties might provide for exceptions to this general principle (e.g. diplomats, military personnel). So if you committed a crime and are caught before leaving the US, you will most definitely be prosecuted there.
Some countries also have laws allowing their justice system to prosecute citizens for crimes they committed anywhere in the world. One reason for that is that some (many? most?) countries do not extradite their own nationals under any circumstance so prosecuting them locally is the only solution available, lest some serious crimes go unpunished. This procedure is sometimes limited to a specific list of crimes or to things that are forbidden both in the prosecuting country and in the country where the crime took place.
In that case, whether you can be prosecuted again for the same crime would be up to the local court system (with some limits, e.g. in the European Union). Non bis in idem is an important principle in many countries (and in international human rights law) but the standard regarding what counts as prosecution or what might justify a new trial is different and your country of origin would not automatically be bound by the procedural rules in place where you committed the crime. This is especially relevant if you have been arrested but not charged, which might not count as a full trial and would therefore leave the door to another trial elsewhere fully open.
Finally, some countries have universal competence laws, often for especially vicious crimes. In that case, you can also be arrested and prosecuted by a third country.
Once sentenced, you might be allowed to serve your time in your country of origin (there are international treaties about that) but this is by no means automatic.