How to make mipmaps fade to gray?

I’d like to have certain textures fade to 50% gray at higher mip levels. What would be the best way to achieve that?

Don’y know why you need it, but if it is for gameplay reasons, here is something close to what you want:
Since mip mapping occurs based on (mostly) distance from the camera you could just make a material with a linear interpolation between the texture and grey.

Here is an example in which you can set the visible area of the texture and the interpolation distance towards grey.

Roel’s solution is roughly what I was using when it occurred to me that custom mips would do pretty much the same thing in my use case and save a few instructions. As it turns out my image editor of choice, PhotoLine allows the editing of mip maps. (The current version, 19.01, works fine with square images but has a bug with other aspect ratios. The developer knows about it so it should be fixed soon.)

It might be worth noting with this approach the fade depends on screen size of the texture so changes in tiling also affect the result. Basing the fade on “distance from camera” or the depth buffer might be easier to use and tweak.