A Swiss national detained in Iran on espionage charges has killed himself at a prison in rural Semnan province.