A man who left an abusive voice message for MP Naz Shah has been given a suspended prison sentence, prosecutors have said.