There are 2 ways to resolve this that have been discussed by WOTC designers in an official capacity: An older option on a Sage Advice segment of one of their Dragon Talk podcasts from January 2017 (specifically at about 13:12 for ~7.5 minutes), and a newer optional rule provided by Xanathar's Guide to Everything's Dungeon Master's Tools chapter.
Sage Advice: Intent is that spell effect doesn't happen, action cost applies, and DM judges whether spell slot is used
To summarize Jeremy Crawford's statements in the January 2017 podcast, "illegal targeting" is a gap in the written rules (as of the date of the podcast) and it's mostly open to DMs to choose how to handle it. That said, Crawford says the intent for how it should be handled is that the spell should still take up the casting time but the spell effect will not occur and not consume a spell slot (I.E., option 2 listed in the question).
There are enough corner cases with this solution at the time of the podcast that Crawford still recommends that a DM adjudicate each individual occurrence on a case-by-case basis until there is eventually an official printed rule. As an example of why, he says spells such as those which require a spell attack probably should still consume their spell slot since there'd be some dissonance with the fact that those spells can miss, unlike saving throw spells which always "hit" but the target can resist their effects.
(He does not clarify what should happen if something like Eldritch Blast, which targets only creatures, actually hits a non-creature in this case.)
The flavor reason for this is that he views spells as essentially trying to make a magical connection between the caster and target. When that connection is established, the energy of the spell is consumed in producing the spell's effect - but if the target isn't one the spell can make a connection to, nothing happens and that energy isn't expended.
He views spell attack spells as a different category; if I had to guess why, it's likely because they mainly produce some effect that then follows standard attack rules in trying to reach the target.
Xanathar's Guide to Everything (optional): No spell effect, action cost applies, and spell slot is expended
As of Xanathar's Guide to Everything's release in November 2017, the (optional) rule for resolving invalid spell targets states (p. 85-86):
If you cast a spell on someone or something that can’t be affected by the spell, nothing happens to that target, but if you used a spell slot to cast the spell, the slot is still expended. If the spell normally has no effect on a target that succeeds on a saving throw, the invalid target appears to have succeeded on its saving throw, even though it didn’t attempt one (giving no hint that the creature is in fact an invalid target). Otherwise, you perceive that the spell did nothing to the target.
This is in slight contrast to Crawford's earlier statements on the topic above, in that the spell still occurs and consumes a spell slot with no apparent effect.
Not by default
Some spells specify that their target knows they that they are being magically influenced. For example, the target of Charm Person (PHB, p. 221):
When the spell ends, the creature knows it was charmed by you.
In the absence of similar text, the target of Scrying does not know, by default, that they are the target of this spell. This is spelled out in the PHB section on Targets (p. 204, bold added):
Unless a spell has a perceptible effect, a creature might not know it was targeted by a spell at all. An effect like crackling lightning is obvious, but a more subtle effect, such as an attempt to read a creature's thoughts, typically goes unnoticed, unless a spell says otherwise.
A tweet from Jeremy Crawford further clarifies that it is not automatically evident what is, and isn't, the target of a spell.
You know that a creature/object/space is affected by a spell only if the spell's effects are visible, you witnessed the spell being cast on the target, or you've otherwise detected/discerned the presence of the spell's effects.
Since the spell, if cast far away from the target, has no visible effects before the saving throw has been made (or afterwards, if the target cannot see invisible things), most creatures will not know you are casting this spell on them.
Of course, there are plenty of ways that a person could know that you are casting the spell. They could see you casting it while holding a personal item of theirs, or you could have told them ahead of time that you will be casting this spell at a specific time of day. But by default, a target would be unaware.
Best Answer
No, unless there is a perceivable effect
The rule on targets for spellcasting says:
What precisely has a perceivable effect is up to the DM. Something like the Mind Sliver cantrip that is intended to do damage could very well be considered to have a perceivable effect depending on how it is narrated.
There is not an official way to determine NPC reactions
But it is helpful to recognize the difference between an "attack" as the game term and an attack in regular English. The game term is restricted to things with attack rolls and a few exceptions (grappling, shoving).
The common English usage of attack, however, is not restricted to that which requires an attack roll. Anything that someone perceives as being intended to harm could be considered an attack in the mundane sense. If someone knows another person attempted to paralyze them with magic, the would-be victim might reasonably be a bit peeved.