Do you mean writing a novel in which you referred to someone else’s work? Like this, for a made-up example?
Tom crouched low and pulled his jacket up over his head, wishing he had Harry Potter’s cloak of invisibility.
Or this?
Lisa set aside the novel she had been reading. Betty glanced at the cover: it was Gone with the Wind.
I’m not a legal professional, but I’d feel sure there is nothing wrong with that and you won’t get into any legal trouble. If your work got published by a traditional publisher, you’d have the benefit of their legal department’s advice.
You can always look in the front of any book that does name names in this way and see what sort of disclaimer they use, if any. Some authors routinely allude to trademarked brand names as a way of including concrete detail; Stephen King is one who does this, and his books include a disclaimer about the fictitious use of real names.
If you’re writing a nonfiction book in which you discuss and analyze other people’s work or real products and services, it’s unavoidable. Consult similar books and look at their disclaimers on the copyright page.