There are many ways to block applications based on User Agent. You can use ActiveSyncDeviceAccessRules for EAS or EWSAllowList/EWSBlockList.
Besides this you can block those User Agnets already on a load balancer. The main difference is that then the workload is moved away from you Exchange server to the load balancer. In this post I’m going to describe the steps of one possible way to do so taken a F5 load balancer.