It is very possible and IMO absolutely vital that the government can be taken to court for their decisions in the UK. Government officials and departments should be subject to the same legal scrutiny as individual citizens, if not more so.
Furthermore, Palantir is a multinational company with offices in the UK so it will be the UK arm of Palantir that is taking legal action, so technically a UK company is suing the government, not a US one.
However, IMO they do not have a leg to stand on. The contract was blocked due to a unfair procurement procedure. Palantir was literally the only supplier invited to take part, the procurement process wasn't duly submitted to Mayor's Office, and the Mayor's office has a duty to ensure that the best value has been achieved for the constituents of London. So they are perfectly within the law blocking the contract.
Also, Palantir can fuck off. They're already harvesting NHS data and data from other police forces within the UK and our feckless government is just sittimg on it's hands while sensitive information if being handed to a fascist regime.