Formula 1 will return to Portugal in 2027 and 2028 as part of a new deal with the Portimão circuit in the Algarve region.