You can't dynamically change the width of a memory, FIFO or otherwise.
Do you just need to know which bits are valid when you read the data out of the internal memory? If so, then store a record of the LSB and MSB bit positions of the valid data at the same time you store the data. You can store the LSB and MSB tags in the same memory with the data if you make the memory 2 bytes wider.
Depending on what you do when you read the FIFO, it might be easier to store the mask with the data. If the FIFO is shallow, then making the memory 256 bits wider to store the mask might not use too many RAM resources. This would be easier than calculating the LSB and MSB bit positions to create LSB and MSB tags to write to the FIFO, but LSB and MSB tags might be easier to work with when you read the FIFO unless you can simply keep a 256-bit data path on the read side and mask the data after you read the data and its mask from the FIFO.