Because bitcoin mining depends on multiple factors, it is impossible to tell beforehand how long it takes to mine 1 BTC. As new bitcoins are mined only whenever a new bitcoin blockchain block gets validated, and this validation process requires solving very complex mathematical problems known as a hash, the validation time varies. Possible factors to affect the duration for 1 BTC to be mined are, to name a few, computational power, competition over a correct hash, and efficiency of the hardware.
However, in the end, the most defining factor for the mining speed depends on the hashing difficulty of the algorithm designed to self-adjust to a verification time of 10 minutes. This means, in theory, it takes approximately 10 minutes to mine at least 1 BTC. This estimation is based on an ideal situation that is, in practice, impossible to reach. While mining alone, the duration of mining 1 BTC will be far from this ideal case scenario. This is also the reason why so many miners mine in mining pools, where miners can increase the likelihood of their rewards by combining their efforts in mining pools where cooperation increases the likelihood of profits that will be shared.
To increase the speed of 1 BTC mining, the miner should enhance their computing performance. This was initially possible by acquiring CPUs with multiple motherboards, but due to technological advancements, BTC miners most commonly turn to ASIC hardware devices and better mining rigs. ASIC hardware chips are perfectly tailored for this purpose and will perform better than a PC.
In short, the timeframe of mining 1 BTC varies greatly from years (inefficient solo PC mining) to a more tolerable timeframe with better, up-to-date hardware in mining pools where the profits are shared but cumulate with time. And the cost? That would vary even more depending on your location, energy source, and energy price. For example, a 2021 published research paper found Kuwait to be the optimal geographical location for crypto mining due to the concentration of cheap electricity. Besides this, cheap energy optimal for bitcoin mining has been found in Central Asia, the Middle East, and North America.
Sources