There’s a fantastic book called The Better Angels of our Nature that has some cool stories and debunks some famous myths about freemasonry during the civil war. Long story short, both sides had a significant Masonic presence, and the treatment of Masons during the conflict was respected by most, even if their officer or fellow soldiers were not members of the fraternity.
As a Mason myself it’s fascinating to see these questions, but you should also definitely look at books written on Masonry by Albert Pike, a confederate general who’s library and writings were some of the most important resources in preserving the Scottish Rite in the US following the war. While not the nicest man, he is an instrumental part of Masonic civil war history.