The enlisted men? Absolutely. The officers, no. I believe that most, such as Albert Sidney Johnston, PG Beauregard, etc., all resigned their commissions, which was their right. But if an enlisted man had a term to fulfill, then technically, they could be shot for desertion.
The officers I was thinking of were those recent West Point grads who had not completed their required term of service. More senior officers were, of course, free to resign and go off and rebel.