Steal this idea for my mod.
Too late, I already stole a functional equivalent in having ground armies that would be able to turn planets into Tomb Worlds. Of course, this was months ago and so I didn't so much steal it as get perturbed as to why I couldn't nuke things into dust with Space Tanks.
It was sunk the instant I looked into how the Swarm converted planets and realized that making anything happen/trigger during ground combat was impossible. The only thing you can do is making events that fire after you've captured a planet. It doesn't even work if you lose a ground invasion, because the game literally is incapable of looking at that.
At best you can have a small chance of turning Primitive planets into Tomb Worlds after you've completely squished their armies. Nothing more. Or in my case, having a box that pops up when you've conquered a planet while possessing a certain technology that lets you choose between "pc_nuked" or "not pc_nuked". The only difference between this thread's idea and my final evolution idea is that the nuking is involuntary and the buttons say "Sad." or "So sad." instead.