SAN FRANCISCO — As the career of Hewlett-Packard’s chief executive Mark V. Hurd hung in the balance, a public relations specialist convinced the company’s directors that H.P. would endure months of humiliation if accusations of sexual harassment by a company contractor against Mr. Hurd became public.