China is luring record levels of investment into the country’s technology sector, even as it clamps down on consumer-technology firms like Alibaba Group Holding Ltd. and ride-hailing company Didi Global Inc. Unlike in previous years, when most Chinese tech funding went to internet startups in e-commerce, the bulk of the money in the past year headed into areas that hew more closely to Communist Party priorities, such as semiconductors, biotechnology and information technology. Venture-capital investors put $129 billion into more than 5,300 startups in China in 2021, higher than the market’s last record of around $115 billion for 2018, according...