Is there a way to invest in an index fund minus certain companies?
Note that this is probably a terrible strategy here, though. The most likely effect of adding SpaceX to the index in the manner described is that the price of SpaceX is likely to go artificially high as the index funds fight for the very few available shares.
If you are actually going to do this, you'd probably want to sell out of the ETF before it's added, wait for SpaceX to be fully added to all the index funds, and only then simultaneously buy into the ETF and short SpaceX.