Morphogenesis of living systems involves topological shape transformations which are highly unusual in the inanimate world. Here, we demonstrate that a droplet of a nematic liquid crystal changes its equilibrium shape from a simply connected tactoid, which is topologically equivalent to a sphere, to a torus, which is not simply connected. The topological shape transformation is caused by the interplay of nematic elastic constants, which facilitates splay and bend of molecular orientations in tactoids but hinders splay in the toroids. The elastic anisotropy mechanism might be helpful in understanding topology transformations in morphogenesis and paves the way to control and transform shapes of droplets of liquid crystals and related soft materials.