Of course you can. Every pro athlete in the NBA, MLB, and the NFL has contract clauses restricting their speech to an extent. For example, in the NFL’s contract:
Par. 2: EMPLOYMENT AND SERVICES. Club employs Player as a skilled football player. Player accepts such employment. He agrees to give his best efforts and loyalty to the Club, and to conduct himself on and off the field with appropriate recognition of the fact that the success of professional
football depends largely on public respect for and approval of those associated with the game.
Par. 11: SKILL, PERFORMANCE AND CONDUCT. …If at any time, in the sole judgment of Club,…if Player has engaged in personal conduct reasonably judged by Club to adversely affect or reflect on Club, then Club may terminate this contract.