This is not possible because this way you would have to create a new layer every time which results in new (yet untrained) parameters.
You could add a global average pooling before the FC layers and give it a fixed output size (depending on the input size of your FC layer)