Can the reshaped stone extends past the original affected area?
For example, would it be possible to raise a stone pillar from the ground using this spell, or extend a stone wall into a ramp?
Spells only do what they say they do. Unfortunately though, the phrase "form it into any shape" is ambiguous. Taken literally, I could form a pebble into a shape the height of Mount Everest.
I find that reading illogical though. I believe the rule as intended is that the shape is changed, but no other characteristic, including the mass. So you are limited in what you can form, by the amount of material in the original stone. This is no more than 125 cubic feet of stone.
Now that said, that still leaves you a lot of leeway. A stone pillar that is two feet across, could be doubled in height while only reducing its diameter to about 17 inches, a loss of only 30% of the size. That may well still be large enough to serve whatever purpose you want.
Similarly, when you modify the stone wall, there may be enough material there to make it thinner in one dimension, while still leaving enough strength and extension in another dimension for your ramp.
A DM would likely have to rule on any given scenario individually. I believe that the main guiding constraint will be whether your desired shape can be managed with the material present, or if you will require additional material. If the former, it should be allowed, if the latter it should not.
Note that implicit in all of the above is that at a minimum, the new shape can extend outside at least one dimension of the original material. After all, you are allowed to reshape a 5x5x5 cube of stone, but such a cube already occupies the entire extent of its shape. The only way to change the shape of the cube without extending outside the original cube would be to remove material. The spell doesn't say that material is removed, and spells only do what they say they do, so the spell must not remove material.
So if you're forming stone "into any shape", that necessarily must include shapes that are larger in one or more dimensions than the original shape.
Note that this does mean that if you create a new shape larger than 5' in any direction, you won't be able to use the same spell to return the material back to its original shape. Something to consider if you want a reversible effect.
From an engineering standpoint, do note however: most stone you come across will be solid, but strong structures can be made while containing a lot of voids. Your DM may not allow you to turn the stone into "foam" (a la pumice), reducing its density and significantly increasing the total volume available to work with, but they would probably at least allow for structural elements such as bracing and or gaps that don't affect structure (e.g. an I-beam can have holes cut from it without significantly affecting its strength).
If they do allow you to manipulate the density of the stone, that grants you even more leeway. Pumice is less than half the density of granite, and so you could more than double the available size of the shaped object, with relatively little reduction in strength.