Resonant excitation of stellar obliquities in hot Jupiter systems with external companions