I am perplexed by this question. According to
Genealogy Trails, John W. Cole is listed as the first Union soldier executed. He was killed by a firing squad for desertion on July 14, 1861. It does not state where the execution took place.
However, on June 20, 1864,
Private William Johnson, 23rd USCT, was hanged and according to a
Harper's Weekly article, dated July 9, 1864, "the facts known about Private Johnson were that he
deserted and attempted to commit an outrage on a white woman at Cold Harbor. Considerable importance was given to the affair, in order that the example might be made more effective. Johnson confessed his guilt and was
executed within the outer breastworks about Petersburg, VA on an elevation, and in plain view of the enemy."
Per this
source, he was the first Union soldier/volunteer executed for desertion.
I'm sure I'm making this much harder than it is. I look forward to seeing the answer.