A military court in Mogadishu found them guilty of killing five people, including four members of parliament.
One of the MPs was the popular female singer, Saado Ali Warsame, who was killed in a drive-by shooting in July.
Al-Shabab advocates the strict Saudi-inspired Wahhabi version of Islam and is battling the UN-backed government to create an Islamic state.
Latest African news updates
Al-Shabab: Mosquito militants
This is not the first time al-Shabab suspects have been executed by the Somali authorities.
At the time of Ms Ali Warsame's death, an al-Shabab spokesman told the BBC that the singing MP was targeted for her politics and not her music.
Al-Shabab often target politicians, bombing the hotels in which they stay in Mogadishu, and have attacked the presidential palace at least four times in the last three years.
Two suspected members of the Islamist group al-Shabab have been executed by firing squad in the Somali capital.