Former Scottish first minister Alex Salmond has resigned his membership of the SNP amid allegations of sexual harassment.