Forbidding employees from certain locations as a proxy for a protected class - likely illegal.
An example: during the sales tax wars many companies would refuse to hire from a state that would could the employee as a tax nexus. This is mostly gone now as the sales tax fight seems mostly over.
More importantly the COST associated is fixed per employee roughly - having an employee in another state doesn't usually change the amount of tax paid, etc - just who it's paid to.
This won't be entirely true, but it's close enough - and for companies with outsourced HR (think: ADP) it's even easier.
Any company big enough to have a significant number of employees that this applies to would be big enough to eat the cost (and probably already has offices/etc in multiple states as is).
Discrimination against a protected class (like race) is illegal. Geography is not a protected class, and discrimination based on geography is not inherently illegal. But under the doctrine of Disparate Impact, a particular policy of geographic exclusion is illegal if it happens to have outsized effect on a protected class (and has no business justification).
Note that Disparate Impact does not require intention!
I'm not a lawyer. This is not legal advice.