While it may not be able to do it with Bitcoin (since it's way beyond gpu miners), it "can" do with gpu mining ones, which means, AI uses gpu mainly and nvidia as well. So if AI companies like openAI, realizes a way to make chatgpt smarter, and figure out a way to mine at a much higher hashrate than what they normally would, and use their gpu power to do it, they can take over any coin that is possible to be mined.
Fortunately, most of them are gone now, there are few strong gpu mined projects left, most either switched to some other way, or they are just centralized and already mined shit stuff anyways. Aside from that, I do not see how AI could take over bitcoin, doesn't really look like it would be a possibility.
Monero and Ethereum Classic are GPU-mineable. Does that mean they're at risk of an AI attack? They might need to adopt more than one PoW algorithm to protect themselves against this. Just like how DigiByte is doing with a multi-algo approach. What could threaten Bitcoin in the long run is quantum computing. But developers already have that figured out. So Bitcoin will remain "immortal" for now.
Even if "all hell breaks loose", the community can simply revive the project with the source code. I think AI will eventually end up benefitting Bitcoin by making it "smarter" and more efficient. We can never tell what will happen in the future. All we can do is hope for the best.