If I'm understanding correctly, it seems like you always want the error to be sent back in JSON instead of content-negotiated as XML? This seems strange since if a client is asking for a response body in XML, they typically want error messages to be sent back in XML as well.
But if you really must, here's how you'd go about doing it:
public XmlDocument Get(int id)
{
XmlDocument doc;
doc = repo.get(id); // simplified
if(doc != null)
return doc;
throw new HttpResponseExeption(
Request.CreateResponse(HttpStatusCode.NotFound, new HttpError("Something went terribly wrong."), Configuration.Formatters.JsonFormatter));
}