You almost got yourself killed.
You almost got killed yourself.
You almost got yourself to kill.
1) You almost got yourself killed. [emphatic]
get oneself [killed, kicked out of class, framed, in trouble, run over] get + past participle or phrase here means: to find oneself in a situation where something is done to you.
2) You almost got killed yourself. [this implies others were killed]
- He almost got in trouble himself. [others did get in trouble]This emphasizes that he did not but others did.
3)You almost got yourself to kill.
Ok, well, this one is a bit iffy. It can mean: you almost convinced yourself to kill.
to get yourself to do something.
Usually, you get others to do something.
I believe the meaning that you are looking for is conveyed by the first expression. That is the expression used:
get + somebody + past participle
It means you were just about to kill yourself, or you put yourself in a situation that was leading to your death.
The others are also correct, but they have different meanings. The second one means you yourself were about to be killed. The third one means you almost forced or persuaded yourself to kill (somebody).