Mexico, a heavyweight in oil production, took a firm stand against climate change by passing a law that would make it the second nation after the United Kingdom to institute legally binding carbon targets.