Hi there,
for the I2c slave on the Mbed device you need to use I2CSlave API, and its method called address will set address defined by user.
For detecting I2C on the RPI side, I recommand to search on internet but it will be something like this.
This can help with start on the RPi side. And watch out for on pull-ups.
BR, Jan