It is actually a breach of contract rather than a violation of statute in many jurisdictions. Drinking alcohol on board other than that served by the cabin crew would normally violate the "conditions of carriage" that you enter into when you purchase your ticket. The cabin crew then have the right to remove the "offending" alcohol, normally on the condition that it will be returned to the passenger at the conclusion of the flight.