Steve was holding the truth about Tony’s parents death during Age of Ultron, and being truthful was a part of an Asgardian’s worthiness.

He wasn’t worthy at the time and in Endgame he was worthy. Simple.

The one yielding mjnoir should have a need of doing so except being worthy,
Moreover here the need was greatest,to save the lone master of the hammer itself.
Hence cap was able to yield the hammer in endgame while in age of ultron he had no need of lifting the hammer

All the answers are wrong, he actually could but he didn’t show his pride and he didn’t want Thor’s ego to go down and you can see he even bulged it a little bit, and in endgame we see Thor says the he knew it which is referring to Age of Ultron.

The director himself that he could do it all along but he just chose not to do it as Thor would be affected as he might wonder where his place is and when steve budged it a bit you could see that look on his face.