i think it depends on the attitude and the frame of mind
a care to keep in mind the fact that it's a business of maintaining fitness of a frail and mortal bag of bones and impurities may negate the tendency of the attachment to body and self-association with it to become stronger, which such type of activity in my opinion is prone to foster
but if one IS a Buddhist they must be able to skilfully counteract that tendency
in any case the motive for going to gym for a Buddhist should not be improvement of bodily appearance but rather health considerations in the frame of mind along the lines of the attitude to eating recommended for monks in the suttas
And how does a monk know moderation in eating? There is the case where a monk, considering it appropriately, takes his food not playfully, nor for intoxication, nor for putting on bulk, nor for beautification, but simply for the survival & continuance of this body, for ending its afflictions, for the support of the holy life, thinking, 'I will destroy old feelings [of hunger] & not create new feelings [from overeating]. Thus I will maintain myself, be blameless, & live in comfort.
Aparihaniya sutta (AN 4.37)