This question doesn't explain what is the use for this phone number, and why this format is needed. There can be several different user cases, in which case there isn't a single "one size fits all" answer.
In this scenario, OP just needs to add a phone number somewhere. This is very simple, and many answers above covers this case. The only caveat is localization : is the site targeted to an international audience within a country , a regional audience or a local one? In the first case, we'll need international code, in the second case, only area code and in the final case local code may be enough. This way, we avoid unnecessary cognitive load, improve recognition and ability to remember the number, making it easier for the user to dial the number as well.
Please note this is specially true in media: if the number is meant to be used on a site or app, yu'll probably need international codes since the audience you'll reach will be wider, UNLESS you want to restrict access to a single country. If you're using this in magazines, you'll probably leave out international code, using only area code. Finally, on a billboard you won't use any area code, just local number.
In this case, the number will be added by different (unknown) users and we need to define an input format. First thing we need to know is what I mention above. For example, if the number the user will input is always inside a country, it's useless and confusing to ask for international code. Additionally, there are libraries that automatically prefill country code based on geo detection or country input from a previous field. This is a recommended way so you don't have to worry about users using
+ for international code.
Once you define this is to let the user type the number the way they would dial it on their phones. Hence, no spaces or dashes, only numbers.
The masking scenario
The most common problem with dynamic numbers is that some developers feel the urge to mask inputs so they look nicer (which they do). However, this is very problematic and should be used only to restrict numbers. Alas, this will never work for international numbers (see answers and comments in this page about the many diiferent possible formats) and you'll need to be incredibly sure about the numbering system. A quick example: my city code is
011. My parents city code is
02477. Imagine trying to mask this. And we're talking inside the same country!
The key for the answer is localization, and based on this, whichever format feels more natural for users.
00as the prefix to dial out is also not universal, which is why universal formats begin with