Well, pre-patch... Putting the urn in your inventory wouldn't prevent them from being culled, it'd just stop them from coming out and spooking it up on the lot when night came around. Non-played sims that died still existed, just without an urn. While they were still around, they would add toward the population limit until it reached the cap, then the game would cull them. The way the game used to cull sims was first ghosts, then unplayed living sims from oldest spawned to recent spawned from what I remember correctly.
Now the system is different and I don't understand the new culling mechanics. :/
As for ghosts, I've been slowly shoving my many ghosts into households by family to try and keep them sort of, "together"--But that doesn't really do anything but declutter my household management window. A few of mine still appear at clubs, but I have a lot of townies so it kind of rotates between living and dead. The dead usually come around when the living sims retire for work or go home LOL. I do use MCC so it changes the sims in the venues to work that way so I don't bump into the same sims everywhere.
The only way for them to not appear is for them to not exist, I think.
Most of my actively played ghost sims live in a haunted mansion aside from this dead kid I got from the Wishing Well. He lives a very spoiled life in my legacy's ancestral home :^)