STM32 I2C Read Variable Length message from Slave
Every byte transmitted over I2C requires acknowledgement. When slave is transmitting data back to master it is the master's responsibility to either allow slave to continue (by replying ACK) or telling it to stop (by replying NACK).

So, if you send the number of bytes N available for reading first then your master can simply continue reading and replying with N-1 ACKs and finish it all up by replying NACK before issuing STOP condition.

Alternatively, if your data format allows it, you can mark the last byte as "end of data". For example 7-bit data can be marked by 1 bit high. The data that is a subset of 8-bit values can be marked by any value outside of that subset. Or you can reserve two values as ESC and EOD signals etc.

Note that all these methods are generally less efficient than sending one message length byte first. After all, even if there was some "magic" 1-bit way to end transmission from slave side in I2C protocol, you would be saving only 7 bit time on one transmission.