Most, if not all, states have laws on the books that prohibit having an open alcohol container in a car. Those have nothing to do with whether or not a cop is present when it’s opened.
I know a judge that left the scene of an accident he caused, drove home and was found with an almost empty glass of wine when the officers arrived.
He knew the consequences for leaving the scene were less than a dui.