There is no cheat code in The Sims 4 to kill a Sim as such, but it is possible, if you own the expansion The Sims 4 Cottage Livingto precipitate the disappearance of one of his characters.
If you don't have the extension, there's no alternative but to use the mod UICheats and manually decrease the need bars.
How to kill a Sim with a cheat code in The Sims 4 Cottage Living?
Total Time: 1 minute
Activate the testingcheats cheat code
Open the cheat console and enter the cheat code testingcheats true
Find the Sim and select it
Press the Shift key and click on the Sim at the same time to open the debugging interactions.
Click on the "kill" interaction
Select the "Kill" interaction and then "Get killed by a bad killer rabbit".
Watch the fight
The ferocious rabbit will attack your Sim and kill him. Since this is not the normal behavior of the game, the rabbit may not appear but your Sim will die at the end of the fight.
I don't know how to "kill" interaction
With the rabbit technique, yes, it's applied to the sim you're requesting interaction with, even if you click on someone else.
Is it a mistake to think that these are sims from our home?
Isn't the sim you want to kill in your home?
The problem when I do this is that instead my sim gets killed 😭