For that you'd compute the wackiness of a person's current revealed utility function with respect to the one they had five minutes ago over the last four days and add all the wackinesses together. If this result is more than four standard deviations above the average they can be considered insane.
I'm not sure that really captures most of what passes for 'insane'.
Followup To: Are You Anosognosic?, The Strangest Thing An AI Could Tell You
Over this past weekend I listened to an episode of This American Life titled Pro Se. Although the episode is nominally about people defending themselves in court, the first act of the episode was about a man who pretended to act insane in order to get out of a prison sentence for an assault charge. There doesn't appear to be a transcript, so I'll summarize here first.
Similar to trying to determine if you are anosognosic, how do you determine if you are insane? Some kinds of insanity can be self diagnosed, but in John's case he has lots of evidence (he has access to read all of his own medical records) that he is insane, yet continues to believe himself not to be. To me this seems a level trickier than anosognosis, since there's no physical tests you can make, but perhaps it's only a level of difference significant to people but not to an AI.
Edited to add a footnote: By "sane" I simply mean normative human reasoning: the way you expect, all else being equal, a human to think about things. While the discussion in the comments about how to define sanity might be of some interest, it really gets away from the point of the post unless you want to argue that "sanity" is creating a question here that is best solved by dissolving the question (as at least one commenter does).