A former official from Nagorno-Karabakh has been sentenced to 18 years in prison after being found guilty of espionage.