On one side plantigrade posture provides more stability and energy efficiency while standing due to having more contact with the floor and in the case of humans more energetic efficiency for long-distance walks at low and medium speed, due to a "double pendulum movement", which impulse the leg below the knee by its own inertia, saving energy. On the other side, digitigrade and unguligrade provide more speed increasing the mobile segments of the leg, also increasing the stride distance and it looks like in the case of bipedals (but more specific the humanoids) it could increase the pressure from weight over a smaller area.
This question will be highly related to this other one: How to correctly insert a kangaroo like balance and support tail in a humanoid? but this time focusing on improved leg shape or design which would combine many remarkable features.
The problem with this is that no extant or extinct digitigrade bipedal creatures are known as having a walking endurance as humans, like many dinosaur species and sthenurine kangaroos (which walked on hoofs, so maybe more like unguligrade). I don't have any knowledge about high resistance bipedal dinosaurs, the most of them could be ambush predators with fast bursts to catch preys, and with the sthenurine kangaroos being more like slow leaf searchers which walked between trees to search food.
For the part of walk resistance, canines are the second ones after humans, have digitigrade legs and honestly are not behind at all of humans (just in specific conditions), horses are another group of animals with a high speed and resistance during relatively long time and are unguligrade. The problem with these two is that are quadrupedal, reason of why the problem that I mentioned about the weight and area distribution is supplied by having four legs in contact with the floor.
That let with the possible better examples (?), to develop this, ostrich, which I remember to read, have been seen running to 50 km/h during 15 km, this thanks to the energetic tendons of its legs, kangaroos also have energetic legs but with another kind of locomotion, increasing the step by jumping, the problem with both is notorious different posture compared with the humanoids and so inferior energy saving at slow motion.
I am gonna add to example images to compare between possible designs and how mix the features to get the "universal" most versatile possible leg.
This image shows how a human leg would look if it were shaped similar to dogs, horses, and flamingos, in order from left to right (the leftmost picture shows a normal human leg). Image by Satoshi Kawasaki.
This image for an unguligrade human shows notorious changes on the legs proportions.
And the last the Sthenurine kangaroo, putting focus on the legs, with a hoof and changing between ungulidrade and digitigrade.
This question is basically asking for help to solve what combination of characteristics and mechanisms would allow this "universal" leg for a humanoid to function, what anatomical changes would be required, changes in proportions in the bones, muscles and joints. For example one of the solutions that I considered is some kind of locking but I am not sure how it would work.