Yes, an employer can have rules in place that prohibit employees from interoffice relationships. It is legal for your employer to have restrictions against fraternization in the workplace. However, this is an employer-specific rule, not something that is mandated by state or federal law. In California, dating a coworker is not illegal.
California is an at-will employment state, meaning an employer does not need a reason to terminate your employment. Your employer can fire you for violating company rules by dating a coworker or for no reason at all. Your employer may also have the power to demote you or penalize you in other ways for breaching a nonfraternization clause. Carefully read over your employment documents and speak to human resources before dating a coworker.