One may speculate on this, but this was already taken into account in the design of Bitcoin. Essentially an attacker would not choose to attack the network because it would hurt their own investment. In the whitepaper, Satoshi states:
if a greedy attacker is able to assemble more CPU power
than all the honest nodes, he would have to choose between using it to
defraud people by stealing back his payments, or using it to generate
new coins. He ought to find it more profitable to play by the rules,
such rules that favour him with more new coins than everyone else
combined, than to undermine the system and the validity of his own
Now to speculate, if there was another reason which made it more profitable to attack the network than to support it, those who support the valid chain could hard fork and put a new consensus rule that would put the attacker at a disadvantage. A potential solution commonly discussed is using a different proof of work algorithm, which would make their current mining hardware basically useless.