Northern Nigeria is predominantly Muslim and the states in the region use sharia courts to punish residents for crimes ranging from adultery to blasphemy.
Adam Dan Kafi, the head of the Hisbah religious police in the Ningi local government area of Bauchi said the three men were arrested on Jun 14 and charged in a sharia court.
The men, including a 70-year-old, all confessed to the crime even though they were not represented by lawyers, Kafi said.
He said Judge Munka'ilu Sabo sentenced them to death on Thursday but they could appeal the sentence within 30 days.
Any death penalty passed by sharia courts in Nigeria needs the approval of the state governor.
In Nigeria, like most parts of Africa, homosexuality is generally viewed as unacceptable.
Nigeria, Africa's most populous nation, has a law that allows lengthy prison terms for those convicted of public display of same-sex relationships and people entering into a same-sex marriage.
The ruling in Bauchi could also shine a spotlight on the place of Islamic sharia law in a country whose constitution is neutral on religion.
Last month, a Nigerian singer asked the Appeals Court to declare the sharia penal code in another northern state unconstitutional. A ruling is expected before October.