I'm not sure if Factorio supports sprite atlases for entities. It might be an option to generate exactly 9 different tiles: 4 (tl, tr, bl, br) for the corners, 4 (t, l, b, r) for the edges and one for the center. That way any size of chest would be possible without any additional sprite generation. For chests < 3x3 just skip the edge sprites along the sides shorter than 3 and the center sprites, for chests > 3x3 just repeat the edge and center sprites.
Or alternatively how about generating the needed chest sprites in the game on demand?