Maybe
Whether or not this is possible depends on whether you interpret the rules such that counterspell targets a creature or not.
Counterspell says
You attempt to interrupt a creature in the process of casting a spell. If the creature is casting a spell of 3rd level or lower, its spell fails and has no effect. If it is casting a spell of 4th level or higher, make an ability check using your spellcasting ability. The DC equals 10 + the spell's level. On a success, the creature's spell fails and has no effect.
I think the interesting thing to point out here is that the counterspelling caster is the one making the check, not the entity whose spell is getting countered. If the interrupted creature were the target, I would expect it to have to make the check.
As it is, Counterspell doesn't really declare a target, though it speaks about the interrupted spell as though the interrupted spell is the target.
Normally, spells are not among the things that one can target. There is some gray area on this matter though due to fact that sometimes wording is vague or specifically overrides the general rules
Based on the popularity of the competing answers to this question, there is some disagreement on whether counterspell targets the caster.
I believe it does not, and if it doesn't target or affect a creature, it therefore can't target the shield guardian to be cast on it and stored by the guardian.
Some spells create an area of effect and could be said to fall on a creature without directly targeting it. For example, a group of creatures engulfed by a fireball might be said to have the spell cast on them even though fireball doesn't directly target creatures. But counterspell is not an area affect and its wording focuses on the spell being interrupted and doesn't really deal with its caster at all.
If you interpret the wording of counterspell such that it does target the caster, then there's this to bear in mind: counterspell has a casting time of one reaction that features the caveat:
which you take when you see a creature within 60 feet of you casting a spell
This means that you can only cast counterspell in response to someone/thing else casting a spell. You might consider having the guardian cast a stored spell which you then counterspell (meaning it would take two spellcasts to store a counterspell).
It's also worth mentioning that, because counterspell is a reaction to another spellcast, it requires the caster to use one turn to command the guardian to cast the spell on its turn (and provide the necessary parameters for that spell to be cast) and then wait to cast counterspell during the guardian's turn.
Also of note: the counterspell interrupts the guardian's casting of the first spell. Since the first spell is not successfully cast, it is instead replaced by counterspell.