Yes, once the bottle has been opened, it is considered an open container, even if you put the cap back on.  Drinking behind the wheel is extremely dangerous, and the law is designed to prevent that.  No court is going to allow you to get away with drinking behind the wheel -- or with having a beer that you can drink while behind the wheel -- simply by popping or twisting a cap back on the bottle as the police are pulling you over.