There are two ways you can do this within EE, and others that use add-ons that extend EE's capabilities.
The easiest way is probably to define your variable as a global variable - which you do from the Template Manager page. Instructions on how to do this here. It is straightforward - you go to the Template Variable page in the Control Panel, create a new template variable, give it a value (in the Control Panel interface) and then you can access this value in templates by simply requesting the value using a tag.
The second option is to use a Layout Variable - this allows you to create a variable that you can assign a value to during template processing. You define your variable using a simple tag based system
{layout:set name="someName" value="someValue}
or
{layout:set name="someName"}someValue{/layout:set}
You can then access the value elsewhere by simply calling the value using a tag
{layout:someName}
The only complication with layout variables is that they only get created when a template layout is passed on to a second layout template - you define the layout variables in one template, and then can access them in any other template that follows that one in the layout chain. Sounds complicated, but once you get the hang of it it is pretty easy going.
To go down the add-on route, you might want to check out CE-Variables which provides powerful and easy to use variable features, but is EE2 only. There are others, including Stash and Low Variables - but these are typically both more powerful and harder to use in practice (because they do much more than just offer local variables) - though both Stash and Low Variables do work with EE3 and onwards.
HTH