The resident, Yusuf Abdi, said the group buried a blindfolded man to his waist last Friday and threw stones at him until he died.
An al-Shabab official said one of its judges sentenced the man to death because he forced a 13-year-old boy to have sex with him. The al-Shabab member insisted he not be named.
Al-Shabab implements a conservative and austere brand of Islam in areas it controls.
Sheikh Ibrahim Ali, a Somali religious leader in Mogadishu, said homosexuality is controversial inside Islam. One strict reading of Islamic law, he said, is that a married man who engages in a homosexual act should be killed.