It is NOT safe to obtain the grounding from another outlet.
The grounding wire must follow along side the hot and neutral wires of the same circuit for the entire path back to the panel. The reason for this is to minimize the inductance in the event of a short circuit to any grounded metal, either in work boxes, or in the powered equipment itself (such as the multi-outlet box). Surge protection will be much less effective in cases where the surge is a differential between hot/neutral and ground (which actually is a common type of surge) due to this same inductance.
Inductance is minimized when the wires with the current going in both directions are close together. Their magnetic fields overlap and mostly cancel each other out (there will be a field inside the cable between the wires). When the wires are far apart, their magnetic fields will extend a greater distance and there will be more inductance. Also, metal located inside the "loop" between the wires can be affected by the magnetics (sometimes in a hazardous way).
To correctly upgrade a 2-wire circuit to 2-wire-plus-ground circuit, the cable must be replaced with one that has integrated ground. In some rare cases, the proper cable may have been run, already, but an ungrounded outlet was used.
Simply running a single wire along side the old cable is also NOT safe. The wires of a circuit, when conducting current, will try to physically move apart from each other due to the orientation of the magnetic field. Physically binding the new single wire to the cable with cable ties not further than 6 inches apart for the entire length could avoid that issue (but is still not code compliant). If you are doing that much work, just replace the cable with the proper type. FYI, this was one of the hazards of older knob and tube wiring. Single wires inside conduit are known to move around, but the conduit sufficiently confines the movement so all you get is some noise.
In many cases you can obtain much (but not all) of the safety of grounding with the use of a GFCI outlet. The grounding wire still cannot be used in this case. It just gives a safer 2-wire load. It is not sufficiently safe for appliances that have frequent human contact, like a computer.
DO NOT connect the ground wire to the grounded (neutral) conductor, as this could lead to current flowing through the body of the dryer (and potentially through you).
The installation guide for the dryer will have wiring instructions for both 3, and 4 wire configurations. Check the manufacturers documentation for proper wiring, but I would say the first image is likely correct.
Instructions from random Maytag Installation Instructions (PDF)
3 Wire Cord
4 Wire Cord
Update:
After doing some research, and looking at dryer wiring diagrams. It turns out that the green/yellow wire is not a ground wire, it is a neutral to case bonding wire. When this wire is not in use (in a 4-wire installation for example), it is simply connected to the neutral terminal and is unused.
Best Answer
Absolutely. You are allowed to retrofit a ground. In fact, NEC 2014 greatly softened the rules for retrofitting grounds (I believe this was legal before, but now there's no question.)
You can use green or bare wire, but if you use bare, use solid. It needs to be 10 AWG. The basic rules of laying the wire are the same as any other kind of cable. How often to fasten it, make splices inside junction boxes, etc.
Ground can follow any route back to the same panel the circuit is served out of. It can take any feasible route and does not need to run alongside the supply cable. (since current only flows momentarily during a fault condition).
It will suffice if you can reach a nearer junction box which has a 10 AWG or larger ground path back to that same panel, such as a water heater, range, air conditioning unit etc. Intact steel conduit counts as a rather thick ground wire. (Grounds can be shared because current only flows during a fault condition, and two circuits faulting at once isn't likely).