If you know how defend your positions, you may do so. If you don't have enough to back your claims, do not try to defend your positions with partial truths or lies: it hurts more than it does good.
It depends on what you mean by "speaking negatively".
If it is just basically badmouthing ("ah Islam is stupid, blah"), you can simply leave, you don't have to enter conflict over vain useless talks, you should use your time on this earth more wisely.
"When thou seest men engaged in vain discourse about Our signs, turn
away from them unless they turn to a different theme. If Satan ever
makes thee forget, then after recollection, sit not thou in the
company of those who do wrong. (Quran, 6:68)"
"So leave them to plunge in vain talk and play about, until they
encounter that Day of theirs which they have been promised!- (Quran, 70:42)"
If it is "speaking negatively" as in "in Islam, women are asked to put on a veil", then there is not much you can do. Some of the things are considered negative by some people, and positive by others.
If it is "speaking negatively" as in pure falsehoods, such that "In Islam, parents eat their kids", well you can debate them if you want, or you can simply say "that is not so".
If it is "speaking negatively" as, let's say, more objectively negative things, such as "Islam allows a man to own another man", then, here too, there is not much you can do.
I am unaware of any religious decree that compels you to speak out. It is considered good to speak out against evil (mounkar) and to advice to do good (ma'arouf), but it is not compelling. As long as you are not an accomplice to the evil.