Yes, that should work. However, you have to be cautious with any overclocking on your system. The pre-built PCs usually have a tailor-made setup for the hardware that's currently installed. Meaning, the airflow/cooling and the PSU's capabilities are laid out exactly for what they use in that system, and not much more (to preserve their profit margin). This is also the reason why they might make less overclock options available in the custom BIOS they use.
Now, if you flash the original board's BIOS, you have all the OC options available again, but now you can easily go beyond what this PC was designed for. So you have to be aware of that and keep an eye on everything. What's more, with the 9th gen CPUs, they started to heavily bin the CPUs in the factory (pre-select according to the silicon quality). The 9900K was more extreme than any consumer CPU they released before, and required a strict binning of the silicon to achieve the high frequencies at a high VCore and power draw. So unlike the 8th gen CPUs which were more overclockable, on 9th gen it became less, as it was much more depending on the silicon quality when it comes to the higher CPU models. So you can't turn an i7 into an i9 easily, the silicon quality simply is worse, so it would require excessive VCore and the power consumption would skyrocket.
This theme of Intel already going to the limit of the CPU's capabilities really started with the 9th gen CPUs, and continued more and more with 10th, 11th, and now 12th gen. When you now get a higher CPU model, you can pretty much forget about overclocking completely, as they squeezed 99% of the capabilities out of it already. For the last bit of performance, you would immediately get a huge increase in power draw and overwhelm most CPU cooling.