A Swedish court has sentenced a far-right politician to four months in jail for two counts of “incitement against an ethnic group” after he made comments at political rallies two years ago.