You may advise them kindly and respectfully if it is possible. But if they are not willing to listen then avoid them when they speak like this.
and when they listen to anything nonsensical, they ignore it and tell such people: “For us, our deeds and for you, yours; peace be to you; we do not want to engage with those who are overcome by emotions. (Qur’an 28:55)
Avoid them when they are like this and you may speak to them when they stop.
He has revealed in this very Book the instruction that wherever you hear that God’s revelations are being rejected and ridiculed, do not sit there with those [who ridicule them] until they get engaged in some other talk, otherwise you too will become like them. It is the verdict of God that He shall gather all such hypocrites and disbelievers at the same place in Hell. (Qur’an 4:140)
And avoid doing anything to provoke them that may cause them to repeat such behavior.
[In spite of their foolishness,] you people should not abuse those they invoke besides God, lest crossing the limits they start abusing God in their ignorance. [This is because] We have made the actions of each community seem pleasing to itself. Then [one day] to their Lord will they return. At that time, He will inform them what they have been doing. (Qur’an 6:108)
Lastly Islam has not made one obligatory to hold ties of friendship, only blood relatives.
Discussion 94322