Structural phase transitions in cold atoms mediated by optical feedback