Not if you are on a work visa that is tied to a particular employer.
Most types of work visas (H1B, L1, TN, E3, etc.) authorize you to work only for the sponsoring employer.* When an employee on a work visa gets an opportunity to be involved with an exciting startup, they frequently believe this restriction will not apply if they work for the startup on nights and weekends for free, until the startup itself is able to sponsor them for a work visa or green card. The rationale is that since they are not getting paid, it is not “work.”
This is not the view that immigration law takes, however. If you are performing duties for which a person would normally get paid, you are probably “working” under immigration law, regardless of whether or not you are actually getting paid. Both you and the company will be in violation of the law unless you obtain work authorization for that particular company.
But I have 10 friends and a cousin who did this without any trouble! if I'm not getting paid, how will they find out?
If you are working, you're likely creating a trail of evidence. Your work may be referenced on the company's website, LinkedIn, or other social media. DHS officers have become adept at using Google to root out unauthorized work. Even a private email account on your phone may be searched by a suspicious CBP officer at the airport when you return from international travel.
Luckily, most types of work visas allow concurrent work with multiple employers, as long as each employer has sponsored you for a visa. For details, see this article.
* EADs, green cards, and certain agent-sponsored O1 visas are not tied to one particular employer. Consult an immigration attorney if you have questions about doing startup work on the side in this context.