Isn’t it true that the criteria for being charged with treason against the United States, the perpetrator would need to be a person owing allegiance to the United States? The Confederacy had formally declared itself a separate entity from the United States. The components of the Confederacy then owed allegiance to the Confederacy. Virginia had declared itself part of the Confederacy. How then can one argue that Lee committed treason?
I can argue that Lee committed treason because, even though the Confederacy thought they were a nation, the rest of the United States disagreed with this contention. Hence, the whole Civil War thing.
Given that the United States considered the states of the Confederacy part of the Union, the acts of those fighting against the United States constituted treason.
There was one way for the acts of Lee (and the rest of the Army of the Confederacy) to be not considered treason. They would have to have won the war and actually constituted a separate nation.