En tyrkisk domstol i Ankara idømte Istanbuls borgmester Ekrem Imamoglu to år og en måneds fængsel for overtrædelse af valgloven.