TOKYO—Japan’s factory output shrank for the first time in three months in December as a decline in machinery production outweighed a small rise in autos, casting a cloud over the strength of the economic recovery. Retail sales posted their third straight month of year-on-year gains in December as low coronavirus cases encouraged shoppers. Record infections this month driven by the Omicron variant, however, are expected to have hit consumer sentiment. Factory output lost 1.0 percent in December from the previous month, official data showed on Monday, pulled down by a decline in output of general-purpose and production machinery, including chip-making equipment and engines used in manufacturing. That meant that output, which fell faster than the 0.8 percent decline forecast in a Reuters poll of economists, dropped for the first time in three months. “Output especially fell among capital goods makers, probably due to the strong impact from the chip shortages,” …