It depends on how you want to do it. Set the entire laser in the turret and you might need a barrel for all the equipment. But I believe that even with that setup it won't be as 'long' as traditional Sci-fi has depicked it.

Or you mount the laser vertically under the turret, and have the turret only have a really good mirror to reflect the beam and a lens and the answer is no, you don't need the barrel.

In order to penetrate an opponent's hull, laser energy must be focused onto a small point on the target's surface, measured in watts or joules of energy per square centimeter. The equation goes like this: I=(P/[L/D]^2)/R^2…

…So how big does our focal dish need to be? Let's go out on a limb and say 10 meters in diameter

In the real world a laser does not need a barrel at all.Also no lenses, the emitter is a flat optic.In deployment, the beam would be directed by a mirror on the gimbal mount. The thing that might look like a barrel would be a shroud to keep things away from the emitter and/or gimbal.

A laser itself can be as thin as a sheet of paper. The body of the laser contains the gain media which is a big factor in the intercity of the laser. Older lasers needed big tube shaped bodies to contain the gain media, but more modern designs put the gain media in a fiber and this can be coiled in almost any shape.

I'd say it would really depend on what you wanted the system designed for, you want the realistic look, advance look or the cool factor. I tend to mix these elements to make some tech marked differently from others. If the laser has a barrel it might look cool, but it clearly isn't as advance as the laser coming from an emitter with the same range and joules of power.