New York developers are transforming struggling office buildings into more than 12,000 new apartments in a bid to help offset the city’s worst housing crisis in decades.