I once learned a term meaning a similar word that cannot stand for it in every context, i.e. a synonym that doesn't work in every instance the original word can (not a hypernym). What is this term?
I think the word you are looking for is near-synonym or plesionym. According to Wiktionary, it means
A word that is almost a synonym but which has a slightly different meaning.
As pointed out by others, "true synonyms" do not exist. At least not when taking pragmatics into account. If we ignore pragmatics for a moment, we could claim that, e.g., At most five people will come to the party and Less than six people will come to the party are (truth-conditionally) equivalent. In any case, even this example is not uncontroversial.
Returning to the question: The term used (at least in semantics) is that of a near synonym. For example, entities in the world that may be referred to both with mass and count nouns (e.g. foliage and leaves, coins and change, clothes and clothing, footwear and shoes). While roughly interchangeable, they behave, morphosyntactically, according to their mass/count role (e.g. pluralization is only licensed for the count expressions in each pair listed above).