It has been reported (for example here) that Donald Trump suggested the UK sue the EU as an alternative to negotiating Brexit. Many interpretations of these comments are possible and as the discussion below shows, I am not having much success making sense of them, but here goes.
I want to ask if the UK government could, through some legal process force the EU to offer a deal more to their liking. In other words could some court or similar body constrain the form of any final agreement or alter the way in which the EU negotiates, possibly imposing some compensation if the EU doesn't comply?
As a layperson the only venue I can think of for such a legal process would be the Court of Justice of the European Union (CJEU). According to the link just given, the functions of the CJEU include
ensuring the EU takes action (actions for failure to act) – the Parliament, Council and Commission must make certain decisions under certain circumstances. If they don't, EU governments, other EU institutions or (under certain conditions) individuals or companies can complain to the Court.
sanctioning EU institutions (actions for damages) – any person or company who has had their interests harmed as a result of the action or inaction of the EU or its staff can take action against them through the Court.
On the face of it either of these could be an answer, but it is not so clear if they really apply here. Note the link does not give a compete list of things the CJEU can do, but only the most common ones.