Optical coherence properties of Kramers' rare-earth ions at the nanoscale for quantum applications