Take a look at the Address book policies functionality: https://learn.microsoft.com/en-us/exchange/address-books/address-book-policies/create-an-address-book-policy
Do note that ABPs do not prevent user communication, if a user knows the email address of another user, they can still contact them. If you need to restrict that as well, you will need to configure transport rules that block messages sent between different branches.