Ras Baraka, the mayor of Newark and a candidate for New Jersey governor, appeared in federal court on Thursday, nearly a week after he was charged with trespassing.