How to make a texture always upright relative to the global Z?
Yes.

The simplest way to do this is by using Object coordinates plugged into a Vector transform node set to transform from Object space to World space:



This will preserve the texture's location relative to the object, so moving the object up and down in world space will keep the textured "glued" to it:



If you don't want this, then you can use the Z channel of the ray position:



This will keep the texture fixed in world space:



Watch the upward translation closely to spot the difference between the two methods.

Note that I tested these with a procedural texture, so I'm not 100% sure it will work with an image texture. I assumed that a procedural texture might suit your needs better anyway. Here's the setup I used: