Rendering with sort of a stencil shader

Hi guys!

I’m sorry the title couldn’t be more descriptive. That’s probably the reason why I couldn’t find anything myself.
Basically I’m trying to do something that comes close to what you see here:
https://wiki.teamfortress.com/wiki/Sentry_Gun#Sentry_Gun_Levels
I’m wondering if and how one could render an object so it looks like something close to the kill-icon. It seems like you would orthogonally render the scene and put different distances (from the camera) into groups, which are associated with a distinct shade of a color (in this example its different shades of grey, haha).

Thanks for your time reading this and for any advice!
Cyba_Mephisto