Yes absolutely ! And you build muscle WAY MORE FASTER with real weights versus calisthenics
The two rules of the gyms are basically : no machines, and 'form before weight' (i.e. master a movements at a given weight without feeling hurt before moving up).
The only two actually dangerous movements are deadlift and squats and it takes at least a PT sesion + a few "form check " on r/fitness to get it right but once it his mastered it's all good. Alsso bench press but it really start being possibly dangerous at 80kg and you are aready quite developped anyway so you are already supposed to master the basic of form an training.
Machines are fine and useful. Better rule might be "don't only do machines". But even then, I'm pretty sure someone experienced could design a routine that would get them good results with nothing but machines.
I'll also say as someone who thought he didn't need the gym because I would do calisthenics/yoga/barbell exercises at home, my back pain never went away until I started lifting heavy weights. I'd say likely because it stregthened my core which supports the back, but I'm no sports scientist.