The U.S. new-car market lost some momentum in the second quarter as affordability, elevated prices and higher borrowing costs continued to weigh on consumers, even as dealers scrambled to salvage sales when key software was knocked offline by a coordinated cyberattack event.