Yes, technically a G19 barrel will work, however the OD of the barrel is smaller than that of a G23 so there will be slight barrel slop in the slide which will cause premature barrel/slide ware and possibly feed issues. Also the ejector is different, some say this causes ejection issues but i have yet to experience that.
There are aftermarket barrels for the G23 in 9mm that will have the proper OD
No a G17 barrel will not work, as the locking lugs are different dimensions