Not only is it legal in California, but there are quotas. Any public company board based in California must meet certain diversity quotas.
https://www.sos.ca.gov/business-programs/diversity-boards
The simplest way to game this is to claim to be a bisexual. This is even easier if you’re already married, since no one will expect you to prove it.