The 23 suspects were found guilty of "trying to overthrow the constitutional order" and "depriving an individual of their liberty", state-run Anadolu news agency reported.
The prosecutor said putschist soldiers forced the presidency's secretary general Fahri Kasirga into an ambulance and took him to the Akinci airbase in Ankara, where the coup was believed to have been organised.
Eighteen of the suspects were sentenced to aggravated life imprisonment, while the other five were given life sentences, Anadolu said.
Two other soldiers were acquitted in the trial.
More From This Section
Colonel Muhsin Kutsi Baris, a former commander with the presidential guard regiment, was sentenced to 12 years in jail for "depriving (Kasirga of his) freedom through abduction", the agency added.
The ruling comes after the main coup trial opened on May 22 of more than 220 suspects, including over two dozen former Turkish generals, accused of being among the ringleaders of the failed putsch.
Several trials are being held across Turkey to judge those accused of coup involvement in what is the biggest legal process of the country's modern history.
Verdicts have already been handed down in coup trials in parts the country but this was the first in Ankara where some of the most important trials are being held.
Over 50,000 people from the public sector including academics, judges, prosecutors, soldiers and police officers have been arrested over alleged links to Gulen.