There is nothing wrong with a woman doing exercise if it is in a place that is only for women, where men cannot see them, so long as that is done to a limited extent and it does not distract her from something that is obligatory, and it does not lead to her missing prayers or delaying them until their time is over, or neglecting other duties.
Among the haraam things that may accompany exercise in some gyms is using music and listening to it. Al-Bukhaari narrated that Abu Maalik al-Ash’ari (may Allaah be pleased with him) said: The Prophet (peace and blessings of Allaah be upon him) said: “There will be people among my ummah who regard as permissible zina, silk, alcohol and musical instruments.”
From this hadeeth the ruling on musical instruments is clear, which is that it is haraam. The fact that they are mentioned alongside other haraam things, namely silk, alcohol and zina, reinforces the fact that they are haraam.
There is no difference of opinion among the four Imams that musical instruments are haraam.
Shaykh al-Islam Ibn Taymiyah (may Allaah have mercy on him) said:
Whoever plays these instruments as a form of worship is undoubtedly misguided and ignorant. But if he does it as a form of entertainment, then the view of the four imams is that all musical instruments are haraam. It is proven in Saheeh al-Bukhaari and elsewhere that the Prophet (peace and blessings of Allaah be upon him) said that there would be among his ummah those who regarded zina, silk, alcohol and musical instruments as halaal, and he said that they would be transformed into monkeys and pigs.
Majmoo’ al-Fataawa (11/576, 577).
Music destroys the heart and distracts people from the truth; it generates hypocrisy in the heart. It cannot soothe the nerves or be a remedy.
Shaykh ‘Abd al-‘Azeez ibn Baaz (may Allaah have mercy on him) said:
Music and other kinds of entertainment are all evil, but they are things that the Shaytaan makes appear attractive and enjoyable, and he calls people to them so as to distract them from the truth by means of falsehood, and so that he can lead them away from that which Allaah loves, towards that which Allaah hates and has decreed haraam. Music, the ‘ood (a kind of stringed instrument) and all musical instruments are an evil and it is not permissible to listen to them. It is narrated in a saheeh report that the Messenger of Allaah (peace and blessings of Allaah be upon him) said: “There will be people among my ummah who regard as permissible zina, silk, alcohol and musical instruments.” End quote.
Majmoo’ Fataawa al-Shaykh Ibn Baaz (3/346).
The Shaykh also said:
As for using music as a remedy, there is no basis for this, rather it is the work of fools. Music is not a remedy, but it is a disease. It is a kind of entertainment which cause sickness in the heart and leads to deviation of morals. The beneficial remedy that can calm the nerves is making the sick people listen to recitation of Qur’aan, beneficial exhortations and beneficial hadeeth. Using music as a remedy is something that gets people accustomed to falsehood and makes them even sicker. It makes listening to the Qur’aan and Sunnah and useful exhortations burdensome for them. Laa hawla wa laa quwwata illa Billaah (there is no power and no strength except with Allaah).” End quote.
Majmoo’ Fataawa al-Shaykh Ibn Baaz (9/429)
Based on this, you should advise these people and tell them that listening to music is forbidden in Islam and that there is no need for this haraam deed. There are many gyms which pay attention to that and they avoid playing music, which makes more people come to them. If they do not respond, then at least ask them not to use it whilst you are in the gym, so that you will not be a partner in this sin, remaining silent about an evil which you are obliged to denounce.
If you cannot do that, then you have to leave this gym: either look for another one, or look for another solution such as buying some equipment to use for exercising at home, which is better for you.