Create Trigger that updates the same table before (or after ??) the Insert
CREATE TRIGGER `populate_country_id` BEFORE INSERT ON `city`
FOR EACH ROW
SET NEW.country_id = (SELECT CASE WHEN NEW.country_id = 0
                                  THEN country_id 
                                  ELSE NEW.country_id END
                      FROM country 
                      WHERE country = NEW.country 
                      LIMIT 1); -- as a precaution


BEGIN-END and DELIMITER reassign are excess.

PS. If NEW.country value is absent in country table then ... anycase inserted data is wrong.