This sort of error usually occurs if you are not connected to the local server even after a VPN connection or if the VPN connection is an issue.
Use the following brew formula to go forward with installing it :
brew update && brew install azure-cli
or you can also use
az login -use-device-code