Honestly, the best bet would be to check if it has a Trademark.
That’s where things can get really problematic, as Trademarks are a nightmare. Trademarks can be used, where us writers are concerned, but there is a very fine line to be aware of. The entire purpose of a Trademark is to prevent someone from using said trademark in a way that is likely to confuse consumers as to the source of the goods or services.
With physical Trademarks, it’s easier to navigate. A company isn’t likely going to care much if there’s a reference to a character in a story having a debate with a friend over which soda company is the best. One like Coke, the other likes Pepsi. Which are real arguments in day-to-days, as is, and it’s easy to see Coke or Pepsi in movies on a regular basis.
Standard Character Trademarks are…harder. A phrase that is under a Standard Character Mark is something I wasn’t aware of until recently. I was actually wanting to quote John Cumming in one of his phrases ("wherever there is great power, lofty position, there is great responsibility") and shorten it down to something a bit more current, and then I came across the entire nightmare that is the Marvel Trademark over a phrase.
Referring to the quote I was intending to use, it came shy of two hundred years before Marvel put a Trademark on it in the early 2000s (2011 or 2012, I think), so I find the entire ‘Trademarking Phrases’ to be utterly ridiculous. Cumming’s quote was in the 1850s, and there are tons of similar quotes from roughly around that time. Including William Lamb, who, around the same time, said, "…the possession of great power necessarily implies great responsibility.”
Given the fact those quotes are almost 200yrs old, quoting the phrases is okay given the authors died over a hundred years ago. So, frankly, I would check if the quote you want to use is Trademarked, then check if it was said by someone else before the Trademark (if there is one), and, if there is a Trademark, see if there’s a way you could rephrase it and still contain the meaning you want.