The greek word for "justified" does have more than one meaning.
https://www.biblestudytools.com/lexicons/greek/nas/dikaioo.html
In Matthew 12:37, we read - "For by your words you will be
justified, and by your words you will be condemned." This is because our words (and our works) reveal the condition of our hearts. Words/works are evidence for, or against a man being in a state of righteousness.
God is said to have been
justified by those who were baptized by John the Baptist (Luke 7:29). This act pronounced or declared God to be righteous. It did not make him righteous. The basis or ground for the pronouncement was the fact that God IS righteous. *Notice that the NIV reads,
"acknowledged that God's way was right.." The ESV reads,
"they declared God just.." That is the "sense" in which God was "justified." He was
shown to be righteous.
Matthew 11:19 "The Son of Man came eating and drinking, and they say, 'Behold, a gluttonous man and a drunkard, a friend of tax-gatherers and sinners!' Yet wisdom is
justified/vindicated/shown to be right by her deeds.