A Survey of Theory of Mind in Large Language Models: Evaluations, Representations, and Safety Risks