The novel 2312, by Kim Stanley Robinson, explores this idea and has a fun chapter describing the process of hollowing out and terraforming an asteroid, using the ejecta to give it artificial gravity and a stable orbit in the solar system. Highly recommended.