Code requirements for moving 3 prong dryer outlet
There are others (Harper, ThreePhaseEel) who will likely provide a ton of details. But in a nutshell:


3-prong does not provide the same level of safety as 4-prong.
3-prong is grandfathered in, but when you make a change you should switch to 4-prong. New work should definitely be 4-prong NEMA 14-30. I don't know if code strictly requires a change to 14-30 in your situation (the real pros can weigh in on that). But from a practical standpoint, once you are already doing the work you might as well spend a few $ on a new receptacle and new power cord and do it right (unlike my electrician years ago).
When you switch, in addition to the new 4-prong receptacle and new 4-prong dryer cord to match it, there is a ground-neutral bonding jumper that MUST be removed on the dryer.


Your pictures pretty clearly show that there is no existing ground, and you have also made it clear that a new cable back to the main panel would be quite expensive. If a retrofit ground using existing wiring (e.g., connecting to the ground of the washer receptacle, provided it is legal (large enough wire or other grounding mechanism)) is not practical then I would consider a combination of (a) replacing the regular breaker with a GFCI breaker to provide protection and (b) replace the existing 3-prong dryer cord with a longer 3-prong dryer cord to take care of the extra several feet. I do NOT recommend using an extension cord - they are available but that is not a good idea, and may even be against code for a nominally permanent installation.