Ms. James, in her first public appearance since her federal indictment, said that she and Mr. Mamdani knew what it was like to be threatened and harassed.