Two of the largest pension funds in the world could be forced to divest billions of dollars of oil and gas holdings by July 2027, under proposed legislation.