Yup you can shoot different calibers in a .40S&W Glock. But keep in mind that you will slightly alter the reliability since it's aftermarket parts. Therefore, most use the altered calibers at the range only.
I have a Glock model 35 with a 40-9 conversion barrel. Fun to shoot 9mm, but have experience failure to eject issues.
Glocks are great!