A historic wartime steam locomotive has returned to Hampshire after a 14-year restoration.