Your problem is how to prosecute Lee as a traitor. The north never formally declared war on the south or recognized it as a sovereign state. The southern states made declarations of succession, not war. Nowhere in the Constitution did it forbid a state from leaving the union. States joined the union; they weren’t conquered, or annexed into it. Lee and his generals who were serving resigned their commissions in the army before hostilities began.
Where in any of that is there anything that justifies a charge of treason?