To participate in a Clan War, tap the"Clan Wars" button in your profile to turn it green. This indicates to the Clan Leaders that you are available for Wars. However, the Leader who initiates the war can also choose you into the war even if your "Clan Wars" button is red.
If you join the Clan after a War has been started or haven't been selected for the lineup, you can only spectate the War.
You are free to leave your Clan during a War, but your War Base will remain visible on the war map and can be attacked by the opponent. Leaving a clan will not affect an ongoing war, and if you return while the war is still on-going you can still do your attacks.
However, you cannot join another Clan War by joining another Clan if your original Clan is still battling it out. Other players will be able to see that you are still part of an unfinished war by checking your profile. You will be marked as ineligible for war until the previous Clan War has concluded.