Oliver L. North and two others indicted for their roles in the Iran-contra affair today gained an ally in their efforts to overturn the indictment: the American Civil Liberties Union.

In a legal brief filed in a Federal appeals court here, the liberties union said the conspiracy indictment against the defendants must be dismissed on grounds that their testimony before Congress was being used against them in violation of the Constitution. The three testified under grants of limited immunity from prosecution.

''It is impossible not to conclude that defendants' testimony has been or will be used against them in violation of their Fifth Amendment rights'' against self-incrimination, the organization said in the brief, which stated: ''The only appropriate remedy in this case is immediate dismissal of the indictment.''

The move by the liberties group, which in the past has criticized Mr. North's actions in the Iran-contra affair, cheered lawyers for the defendants: Mr. North, a retired marine and former White House aide; John M. Poindexter, President Reagan's former National Security adviser, and Albert Hakim, an Iran-American businessman who acted as a financial adviser in the Iranian arms sale. Defendants Request Dismissal