Governments risk $340bn in legal claims for limiting oil and gas projects, study finds