Where does Xcode install if macOS is installed on an external drive?
Apps from the Mac App Store like Xcode install to /Applications which maps to the Applications folder on the data volume in the same container as the macOS installation. This can be moved wherever you desire after installation, but it sounds like this is the location you want anyway.
Xcode from developer.apple.com is the .app bundle inside a compressed archive. You can download, extract and move the app wherever you desire.