Forget the "Virginia doesn't secede" thing. That's not fun and wanders away from the OP because it's not necessary.
Instead, the obvious way is to have Lee fight for the Union before Virginia secedes. The late Robert Perkins pointed out that Robert E. Lee was stationed in San Antonio in February of 1861, when Texas had voted to leave the Union. In OTL, David E. Twiggs was in command of The Department of Texas, but at the time he was having health issues. If he was too sick, then Robert E. Lee would be in command, and when Texas votes to secede and attempts to take the Alamo, Lee would not have just given up and let Texas take the installation. By the time Virginia secedes, he's already cast his lot in with the Union.
As it happened, later, Harry Turtledove wrote a short story about this.
So now that we have that out of the way, I'd be interested in hearing opinion on a Union Lee.