In a scathing decision released Tuesday, a federal judge in Northern California ruled that a unit of UnitedHealth Group, the giant health insurer, had created internal policies aimed at effectively discriminating against patients with mental health and substance abuse disorders to save money.