Not possible by design.
Use a transport rule instead:
https://learn.microsoft.com/en-us/microsoft-365/security/office-365-security/configure-the-connection-filter-policy?view=o365-worldwide#skip-spam-filtering-for-a-cidr-ip-outside-of-the-available-range