The Ethiopian Federal High Court says they had been accused of planning to carry out terror attacks inside the East African country.
The state-affiliated Fana Broadcasting Corporate quotes the court ruling as saying three of those sentenced had been planning to establish an Islamic state.
Court officials say the defendants were active between 2010 and 2014 in six cities including the capital, Addis Ababa.
The charge sheet says the defendants recruited individuals and sent them to neighboring Somalia for training. Al-Shabab, which has links to al-Qaida, is based in Somalia.