You should be able to turn the clamp nut by the wall...
...which will allow the horizontal portion of the drain connection to pull out of the wall. It may have enough slide connection so it can be reclamped to use the existing pipe to reach the new down spout on the sink.
If it is not long enough then you will need to purchase new parts to achieve a longer horizontal portion. Do take the old pipe with you to the store so you can see what type and size of parts to place in your shopping basket.
Note that it is quite common to use a combination of the back wall slide connection and the rotation of the P-trap joint to achieve getting the pipes perfectly aligned with the sink drain. The following picture is an attempt to show how this adjustment works. There are only really two positions where there will be perfect alignment when the horizontal positioning from the wall causes the sink drain center to intersect with the arc of swing of the P-trap.
Note that if the center of the drain hole is farther from the center line of the wall pipe than the radius of the P-trap arc then there is no position where you can get things to line up. In that case then you need to use additional fittings to angle from the wall connection more toward the new drain location.