Suppose a cleric casts Zone of Truth on a captured enemy. Unbeknownst to them, the enemy is a rakshasa. Zone of Truth says (PHB, p. 289):
You know whether each creature succeeds or fails on its saving throw.
But (MM, p. 257):
The rakshasa is immune to spells of 6th level or lower unless it wishes to be affected.
Assuming the rakshasa doesn't wish to be affected by the Zone of Truth spell, does the caster know this?
More generally, does a caster know when targets are unaffected by a spell they have cast, either because they have made saving throws, or because they are outright immune to the spell or its effects (e.g., casting Ray of Sickness on a shadow demon, which is immune to poison damage and the poisoned condition)?
There's nothing RAW that indicates that players would know whether or not a creature is affected by most spells, though presumably in the instance of Ray of Sickness, players could infer whether the spell had taken effect based on a creature's behavior.
Does the hobgoblin captain slump for a moment, resting on her spear? Does the shadow demon react at all to the beam? Those are probably telling.
Zone of Truth appears to be a little different since the caster explicitly knows whether the target succeeded or failed the saving throw, which can only occur if the creature is affected by the spell in the first place; a creature which isn't affected by the spell never makes a saving throw. In this way, the caster would know if the hostage weren't affected, if only circumstantially; instead of having succeeded or failed to resist the spell, the Rakshasa would effectively be invisible to the spell, which would surely be suspicious.