Stan Wawrinka will make a farewell appearance at the US Open - despite initially not being given a wildcard for the final Grand Slam of his career.