En tyrkisk domstol i Ankara dømte Istanbuls borgermester Ekrem Imamoglu til to år og en måneds fengsel for brudd på valgloven.