A federal judge ordered a 14-year-old taken by immigration agents in Marlborough and driven to New York to be returned to her aunt in Massachusetts.