Get a conversion barrel; a 40 to 9 often just written as "40-9" ... mine's Lone Wolf brand. It worked so well in my G27 I bought a G26 and sold the barrel for 75% of what I had in it. Other than the barrel, the gun was pure G27; you do need to use G26 magazines. The 40-9 barrel was flawless through about 300 rounds and very accurate. 40-9 conversion barrels are available in G23 stock length. Maybe even extended; haven't look in a while.
I also have a LW 357 Sig conversion barrel that's stock length in my G23. It works in my G27 as a somewhat extended barrel. Other than the cartridge markings, 40 Cal and the 357 Sig magazines are identical. For this conversion, you don't need 357 Sig magazines, just use the 40 Cals.