I bet the two wires that are taped together are neutrals, not grounds. (BTW, that tape should be replaced with a wire nut.) There doesn't appear to be a ground wire in this box. The metal box itself may or may not be grounded by a metallic conduit or armor. You couldn't say for sure without a lot more thorough checking, beyond the scope of a StackExchange answer.
You definitely don't want to connect the ground wire to a neutral. The switch will work but it's not safe at all.
NEC 404.9(B) addresses grounding for switches.
(B) Grounding. Snap switches, including dimmer and similar control
switches, shall be connected to an equipment grounding conductor and
shall provide a means to connect metal faceplates to the equipment
grounding conductor, whether or not a metal faceplate is installed.
Snap switches shall be considered to be part of an effective
ground-fault current path if either of the following conditions is
met:
(1) The switch is mounted with metal screws to a metal box or
metal cover that is connected to an equipment grounding conductor or
to a nonmetallic box with integral means for connecting to an
equipment grounding conductor.
(2) An equipment grounding conductor or equipment bonding jumper is connected to an equipment grounding termination of the snap switch.
Exception to (B): Where no means
exists within the snapswitch enclosure for connecting to the equipment
grounding conductor or where the wiring method does not include or
provide an equipment grounding conductor a snap switch without a
connection to an equipment grounding conductor shall be permitted for
replacement purposes only. A snap switch wired under the provisions of
this exception and located within reach of earth, grade, conducting
floors, or other conducting surfaces shall be provided with a
faceplate of nonconducting, noncombustible material or shall be
protected by a ground-fault circuit interrupter.
So if the box itself is grounded, you can bond the ground wire on the switch to the box with pigtail and a ground screw or ground clip.
If there's no ground available, and you're replacing an existing switch, you can cap the ground and use a plastic faceplate. There are some locations in there where you're supposed to install GFCI protection if the circuit doesn't already have it when you replace the switch.
Even if the code doesn't require it with your old wiring, installing GFCI protection on circuits without a ground is worth looking into, it may not be too expensive and it is a big safety improvement.
If the switch box ONLY has the two black wires in it, then its just a switch leg, with the main wiring run in the ceiling above the light fixture. Without additional wiring installing this device in this location may not be possible.
Best Answer
Unfortunately, no. That red wire is the key. Half-switched outlets need an always hot wire and a switched hot wire. Outlet 1 has that (black and red), but outlet 2 does not. You would need to run another cable to Outlet 2.