The only practical way of doing this I could imagine is in postprocessing
In 3D there are no pixels - so the border that will be “10 pixels wide” close to the camera will be smaller on the object that’s further away. Since postprocessing modifies a rendered scene (ie. basically draws stuff over a 2D picture of the scene) you can pass a screen resolution to the shader and calculate pixel-perfect values in the shader.
This example may help a bit (code) You can see that the resolution is passed to the shader as a uniform.
This may also help - but I’m not sure if it allows you to draw pixel-perfect borders