It is legal to drive with an alcoholic beverage container that has been opened only if the container is:

Any opened alcoholic beverage container must be kept in the trunk of the vehicle, or in another place where passengers do not sit. Keeping an opened alcoholic drink in the glove compartment is specifically prohibited. However, in a bus, taxi, camper, or motor home, these restrictions do not apply to non-driving passengers.
DMV Writen Test