Is it possible to put a function somewhere other than the functions.php file? I.e directly into a template?

I have the following that needs to be called before some code and to make sure this happens I want to place it above everything else in the template:

function set_region_cookie()
{
if(isset($_POST['region']))
{
// Set Cookie
setcookie('region', $_POST['region'], time()+1209600);
// Reload the current page so that the cookie is sent with the request
header('Region: '.$_SERVER['REQUEST_URI']);
}
}
add_action('init', 'set_region_cookie');

Alternatively, if this is relevant only for a specific template, then I don't think you need add_action at all - or even a function for that matter.

Simply place the inner code of your function BEFORE get_header() in your template:

if(isset($_POST['region']))
{
// Set Cookie
setcookie('region', $_POST['region'], time()+1209600);
// Reload the current page so that the cookie is sent with the request
header('Region: '.$_SERVER['REQUEST_URI']);
}