GrapheneOS, at least, does this on recent Pixel hardware (confirmed as of Pixel 9 Pro, unknown on lower models.)
It's doing a couple different things, controllable by toggles in settings:
1) Disable 2G network connections globally, which may break a few weird old international roaming connections, but also blocks some old shitty IMSI catchers. Mainly this is done because 2G has little to no protections, blindly offering up globally-trackable identifiers to anyone who asks.
2) "Network notifications" gives the user a notification if their device responds to a request for globally-trackable IDs outside of an established security context. It does not block these requests, just notifies the user.
Pre-5G standards allow the carrier -- or someone impersonating it -- to request the IMEI/IMSI data before establishing an encrypted context. Without going too nerdy, the normal procedure is to negotiate the session using an ephemeral ID and keys known to the carrier and SIM, then exchange the true data within an encrypted envelope. The "Stingrays" do not (supposedly) know the shared key, so they cannot negotiate the encrypted session and have to request the data in the clear, and the OS can tell you this happened, given hardware and firmware support.
5G is stronger, in that it defaults to authenticating using a token derived from the true subscriber ID using a public key, the private component of which is (supposedly) only known to the customer's home carrier, so neither roaming networks nor interception devices can know the true ID. Of course, there are backdoor ways to do this using a null key for "legacy support," and this is one of the things that Android will notify of.
It remains to be determined how strong those "supposedly" elements are.