Unocal Corp. Chairman Fred L. Hartley, his company in the sights of corporate raider T. Boone Pickens Jr., yesterday called for a halt to hostile corporate takeover attempts and said the nation's tax code "favors raiders and needs changes."

"We just believe that this whole merger mania, hostile merger mania, is a disgrace to the nation, and our country has already lost too many fine independent oil companies," Hartley said in an interview. "It must be brought to a dead stop."

Hartley, who has taken a much harder line against Pickens than most of the maverick oilman's previous targets, will be pitted against Pickens today in testimony on the tax implications of takeovers before the oversight subcommittee of the House Ways and Means Committee. Also scheduled to testify is William C. Douce, chairman of Pickens' last target, Phillips Petroleum Co.

The subcommittee began hearings yesterday, listening to some experts who think that takeovers should be controlled by changing tax laws to penalize controversial activities, such as greenmail payments to corporate raiders who sell their stock back to a takeover target at prices above the market. Representatives of the Reagan administration, however, told the subcommittee that federal tax law should not be used to discourage corporate takeovers. Proposals also were introduced yesterday that would eliminate the deductibility of interest expenses in certain highly leveraged takeovers. This change would make acquisitions using large amounts of debt less attractive.

Hartley said he will ask the subcommittee to consider an end to deductions of interest costs on money borrowed for hostile takeover attempts, a course favored by many other opponents of hostile corporate buyouts.

"The taxpayers of this United States should not be forced to pay part of the cost for a raiders' course of action," Hartley said.

Unocal has taken a number of steps to ward off a takeover attempt by Mesa Oil Co. Chairman Pickens, who heads a group that owns 13.6 percent of the big Los Angeles-based oil company, formerly known as Union Oil Co. of California. Unocal has sued a bank that loaned money to Pickens, tightened its corporate charter to make a change in control more difficult and required that any proposals to shareholders be filed at least 30 days before the date of Unocal's annual meeting.

This last tactic led Pickens to demand a two-month postponement of the annual meeting, but Hartley has refused. Pickens is mounting a shareholders proxy fight in an effort to get the meeting date changed. He says he needs additional time to decide how to proceed with his takeover plans or to put up his own slate of directors for election to Unocal's board.

Yesterday, Unocal took another step that could frustrate Pickens, by increasing its quarterly dividend payment 20 percent, to 30 cents a quarter from 25 cents -- a common defensive strategy designed to induce shareholders to hang onto their stock for the additional income rather than selling their shares to a raider.

Hartley said the dividend increase was not so much a pure defensive maneuver as it was a signal of Unocal's opposition to Pickens' often stated contention that the oil industry is inefficient and should be broken up and restructured.

"You can see from that statement that Unocal thinks long term," Hartley said of the dividend announcement. "We want our nation to have oil in the future, and we firmly believe that we are not operating a sunset industry. . . . Pickens can't deliver on his restructuring claims, and, further, his argument is phony."

Rep. William J. Coyne (D-Pa.) testified yesterday that the takeover of Gulf Oil by Standard Oil of California "raises the possibility of an erosion of the local Pittsburgh tax base and the loss of hundreds of jobs. . . . I found nothing in my research of existing law . . . which protected a community from advserse consequences as a result of a merger."