The deal is pending a physical and will guarantee him $4.25 million, sources said. He'll make a base of $3.75 million with a $500,000 buyout on a club option in 2020 worth $6 million.
Flores, 27, hit .267 with 11 homers and 51 RBIs in 126 games with the New York Mets in 2018, when he made $3.4 million. Flores started 73 games at first base, nine at third base and six at second base before his season ended prematurely due to soreness in both knees.
Mets manager Mickey Callaway said in September that Flores was going to receive injections to alleviate the pain, which was attributed to early-onset arthritis in both knees.
In November, the Mets declined to offer him a contract, making him a free agent.
Flores endeared himself to Mets fans when he got emotional during a game against San Diego on July 29, 2015, believing media reports he had been traded to Milwaukee. The proposed swap for Carlos Gomez fell through, and two days later Flores hit a game-ending 12th-inning homer to beat Washington.
In 581 career games over six seasons, Flores is a .262 hitter with 68 homers and 253 RBIs.
The Yankees had acquired Locastro from the Los Angeles Dodgers for minor league right-hander Drew Finley and $75,000 in November.
Locastro, 26, made his big league debut with the Dodgers in 2017, appearing in three games. He hit .182 (2 for 11) this year with 1 double and 4 steals in 18 games, including three starts in center field. He batted .286 with 23 doubles, 4 homers, 29 RBIs and 19 steals in the minors this year, mostly at Triple-A Oklahoma City.
Information from The Associated Press was used in this report.