I've found one solution but I'm sure there can be many others.
It will work much simpler if your fog is grayscale (just apply the color correction after all this stuff)
Let's suppose you want to get rid of the pure white value and keep the rest. Put a seexpr _simple node after your inverted/gamma Z pass. And in the R field enter r<1 ,same for G and B fields .
That will create a black and white mask were all value below 1 get white ( True ) then you can merge it with the Zpass with a multiply operation.
Finally apply the blue tint and you're good to go !