A court has convicted a comedian on charges of insulting religious values and Turkish President Recep Tayyip Erdogan.