Probably not, but some came close
My understanding of the question is that it primarily is asking whether a Secretary of Defense who held that office during a war ever admitted that the war itself as a strategic error.
That seems unlikely, and some searching was unable to find an example, although that does not prove definitively that it never happened. In the USA, there is a strong pro-military sentiment, and so there is little to motivate a Secretary of Defense to say that a war was wholly a mistake, unless they truly believed it themselves. As of now, only two or three wars of the dozens that the United States has fought are both well-known and generally perceived as complete failures: the wars in Afghanistan, Vietnam, and perhaps Iraq.
That said, one can find a few examples of people who came close.
I believe that the closest would be Robert McNamara, who served as Secretary of Defense during the Vietnam War, wrote the following in his memoirs:
We in the Kennedy and Johnson administrations who participated in the decisions on Vietnam acted according to what we thought were the principles and traditions of this nation. We made our decisions in light of those values. Yet we were wrong, terribly wrong. We owe it to future generations to explain why.
In the surrounding context, he does not quite say that the war itself was a mistake, and he mainly criticizes (most) of his own decisions around it, but it is easy to read between the lines and think that he is talking about the war in general.
Another person who somewhat approached this type of statement is Colin Powell, Secretary of State (though not Defense) during the war in Iraq, who defended the decision to invade while implying that it would have been a strategic error if they had known the true intelligence:
“If we had known the intelligence was wrong, we would not have gone into Iraq. But the intelligence community, all 16 agencies, assured us that it was right,” he said on NBC’s “Meet the Press.”
Of course, one might not wish to read too much into this, because he also said this about the invasion of Baghdad:
So I think it was a great success. But the biggest thing was the American people just absolutely fell in love with their armed forces once again.
An additional mention should probably go to James Mattis, who called the Iraq War a strategic mistake in exactly those words, but was not Secretary of Defense until two administrations afterward, and did not make the statements while Secretary of Defense nor near the beginning of the war.
We will probably look back on the invasion of Iraq as a mistake, a strategic mistake