The Lutherans Symbols state that when we come across the word "justify" in Scripture it can mean one of two things: declaring righteous or making righteous. The Apology famously concludes: "Scripture speaks both ways." There are those who have denied that the meaning "declaring righteous" is present. But then, look at Proverbs 17:15
"He who justifies the wicked and he who condemns the righteous are both alike an abomination to the Lord."
Here "justify" CANNOT mean "make righteous." For he who would make the wicked become righteous would be anything but an abomination to the Lord! Here it must mean "declares righteous." The human who dares to assert of an evil person: that evil person is righteous is as abominable as the man who says of one who is righteous: "that man is condemned."
But then, how can the Lord Himself do what He condemns? How do you square Romans 4:5 with Proverbs 17:15? I'd suggest that the difference is in the doer of the verbs. God (and so God in the flesh) CAN do what a mere human being CANNOT do. And His "saying" makes what He says so.