What is your concern with it taking 20 hours vs 1 hour? Is this index re-created on a regular basis?
Would it make any sense to materialize the value of foo(a,b,c) as a generated column (PG12+ natively, or maintained by a trigger before)? Or even bar(foo(a,b,c),geom)?
Do you know if parallel_workers are being used?
JIT is available in PG11, it is just off by default. If it is available, turning it on and trying it seems like the simplest check if it would speed up the index creation.