Not as part of a contract for work, otherwise, the entire contract labor market that involves specific payment for customers hiring workers off of the contact would die as customers would just ignore the “unenforceable” restrictions and hire desired employees without the contracted payment to the intermediary firm.
Standalone anti-poaching agreements between competing firms are generally unenforceable (and also potentially outright illegal and actionable.)