Melbourne, Australia has been running a project since 2015 – scheduled to continue until at least 2030 – to remove at-grade intersections (or "level crossings" as we call them) on suburban rail lines. They've already removed 83, and by 2030 plan to have removed 110. I'm not sure of the total cost, but I'd say in the ballpark of US$5-10 billion. The removal is done by a combination of elevating the rail line, trenching the rail line, and leaving the rail line at the same level but building road bridges over it – adopting whichever solution is most feasible and cost-effective for any given at-grade intersection. The project is run and paid for by the state government, with the federal government contributing some of the funding.
Australia's State of Victoria: population close to 7 million, economy almost US$300 billion (Gross State Product), annual state government budget around US$70 billion. California: population close to 40 million, economy almost US$4 trillion (GSP), annual state government budget of almost US$300 billion. If Victoria can afford it, California can too.