Would they be attached in some way? Or just flying in formation?
Hmmm... with fancy "tractor beams" and "structural integrity fields" and all that sort of stuff already floating around the world of Star Trek... I don't see any reason why component parts of a spaceship can't be held together by anything more than energy.
Interesting thought- but what happens during a power failure? Though I've always envisioned trek tech to be more reliable than our shows and movies protray.
I guess if you have something held in place with magnetic forces, than you could have safety measures for power failure, not unlike safety air brakes on trucks. Springs in the air brake chambers are compressed by air pressure on rigs while driving- any catastrophic air loss instantly releases those springs, and engages the brakes- thereby making runnaway trucks a thing of the past.
So in this case, a similar feature can be in place where the power source holds a mechanical locking mechanism away from those floaty bits held in place, and if the power goes, the mechanical locks automatically engage, thereby keeping said floaty bits from, er, floating away...