Switzerland has sentenced a former Islamic State recruit to 600 hours of community service instead of prison, in the country's first instance of convicting a foreign jihadist fighter.