Here's what John Gill wrote:
Others have been of opinion, that Zechariah the prophet is designed; and indeed, he is said to be the son of Berechiah, the son of Iddo, Zec 1:1 and the Jewish Targumist speaks of a Zechariah, the son of Iddo, as slain by the Jews in the temple. His words are these {a};
“as ye slew Zechariah, the son of Iddo, the high priest, and faithful prophet, in the house of the sanctuary of the Lord, on the day of atonement; because he reproved you, that ye might not do that evil which is before the Lord.”
And him the Jews make to be the same with Zechariah the son of Jeberechiah, in Isa 8:2 and read Berechiah {b}: but the Targumist seems to confound Zechariah, the son of Jehoiada, with him; for the prophet Zechariah was not an high priest, Joshua was high priest in his time; nor does it appear from any writings, that he was killed by the Jews; nor is it probable that they would be guilty of such a crime, just upon their return from captivity; and besides, he could not be slain in such a place, because the temple, and altar, were not yet built: it remains, that it must be Zechariah, the son of Jehoiada the priest, who was slain in the court of the house of the Lord, 2Ch 24:20 who, as Abel was the first, he is the last of the righteous men whose death is related in the Scriptures, and for whose blood vengeance was required, as for Abel’s. He was slain in the court of the house of the Lord; and so the Ethiopic version here renders it, in the midst of the holy house.
. . .
The chief objections to its being this Zechariah are, that the names do agree; the one being the son of Jehoiada, the other the son of Barachias; and the killing of him was eight hundred years before this time; when it might have been thought our Lord would have instanced in a later action: and this he speaks of, he ascribes to the men of that generation: to which may be replied, that as to the difference of names, the father of this Zechariah might have two names, which is no unusual thing; besides, these two names signify much the same thing; Jehoiada signifies praise the Lord, and Barachias bless the Lord; just as Eliakim and Jehoiakim, are names of the same person, and signify the same thing, 2Ch 36:4. Moreover, Jerom tells us, that in the Hebrew copy of this Gospel used by the Nazarenes, he found the name Jehoiada instead of Barachias: and as to the action being done so long ago, what has been suggested already may be an answer to it, that it was the last on record in the writings of the Old Testament; and that his blood, as Abel’s, is said to require vengeance: and Christ might the rather pitch upon this action, because it was committed on a very great and worthy man, and in the holy place, and by the body of the people, at the command of their king, and with their full approbation, and consent: and therefore, though this was not done by the individual persons in being in Christ’s time, yet by the same people; and so they are said to slay him, and his blood is required of them: and their horrible destruction was a punishment for that load of national guilt, which had been for many hundreds of years contracting, and heaping upon them.