The short answer is yes, it’s something you are born with, or at least the potential is there at birth.
Several genes dictate skin colour, inherited from both your mother and father - it isn’t a single gene (although the MC1R gene is the one we all learned was the skin colour-maker.)
The MC1R gene does seem to be pivotal in determining how much melanin you have and the various colour pigments within the melanin - much like the: cyan, magenta, yellow, and black inks in a colour printer - we’re all a mix.
You have a gene that maintains the melanin production: how much you get and where it goes. Another controls the enzyme tyrosinase (you may see on serums for fading melasma that they inhibit the tyrosinase production), if this gene functions poorly, the mechanism to get melanin up to the surface of the skin, won’t be as effective.
The particular bundle of genes you get will limit how much sunlight can tan your skin; however much sun you expose your skin to, there will be a limit to the shade it can deepen. When UV light hits your skin it produces melanin to protect itself, but how much it can do this will depend on your genes. Some people have a high melanin baseline and this provides a much better natural protection from UV rays than someone with very little.
One way to categorise skin types is using the “Fitzpatrick scale’ - there are six types that range from type 1 which is very pale, pinkish, white, usually with blonde or red hair and pale blue eyes, these people have very little melanin and will suffer sunburn even in very little sunshine. Type 6, on the other hand, has lots of melanin and their skin shade is dark brown/black, with brown eyes and brown or black hair, these types are very well protected and darken without burning in hot sunshine.
Your ability to tan may change over time, but this is still due to your genetics and how much sun you’ve been exposed to over the years (so how much exercise your melanin production has done!). As skin ages, it thins and it functions less effectively. Tanning often become less even, in terms of which bits of skin tan, but also the depth of colour. People with pale skin can have very dark areas of melasma appearing just in a few spots. In general, people with skin types 1 and 2 will have a more noticeable change in skin colour due to sun exposure, than those with types 4 to 6.