General Rules
The rules on this vary somewhat by country. In some counties the is no trademark protection unless a mark is formally registers. In others use "in trade" offers a degree of protection even in the absence of registration. The US follows the second rule. Some of Europe follows the first.
But in pretty much all countries trademarks (aka trade marks) are only protected when they are "used in commerce" and are only protected against other uses "in commerce". This mans that a phrase or design or other possible mark is only protected when it is functioning as a mark, that is it is used by the maker to identify or advertise a product or service (hereafter I use "product" to mean either or both).
Moreover a mark is only protected when an alleged infringer uses the mark (or a similar mark) in such a way that people might reasonably be confused into thinking that the infringer's product comes from the same source as the products of the owner of the mark, or is approved, sponsored, or endorsed by the owner of the mark.
A simple literary or pop-culture reference is normally not trademark infringement. This is both because a well-known phrase is not usually protectable as a mark at all, and because a reference to it is normally not infringement, even if the mark is protected.
The likelihood of confusion is a very important concept in trademark cases.
Examples
The phrase "Elementary, my dear Watson" Is often used as a reference to the Sherlock Holmes stories and novels. But it was never used to brand or advertise those stories, so its use in a novel or video game now would not be infringement. Even if a game used that phrase as a title, it would not be infringement, because the phrase is not protected. All this would still be true even if the Sherlock Holmes stories were still being published.
The tagline "In space, no one can here you scream" was used extensively to advertise the movie Alien. It had some protection as a mark (in the US), and might well have been registered for fuller protection (I haven't checked the US register of trademarks, or any other for this phrase). A game titled with this phrase might well be infringing. A game where a character speaks the phrase at some point probably will not be infringing.
Caution
All that said, exactly where the limits of infringement lie depend on the detailed factual situation. Before investing sizable amounts of money or time and effort on such a project, it might be wise to consult a lawyer knowledgeable about trademark law in one's particular jurisdiction, and make sure that the risk of suit is not to great for one's tolerance.