For Unity 2019.3+ | URP | HDRP | Built-in

Silhouette
The Silhouette effect colors each scene element based on its distance from the camera.
This effect works best when the far clipping plane of the camera is set to a smaller value, such that the entire scene just about fits within the camera.