If your Beoplay M5 is added to the Bang & Olufsen app, you can find the 8-digit serial number under "Product information -> Product settings -> About." The Bang & Olufsen app is available for download from the App Store and Google Play Store.
Alternatively, the serial number can be found on the packaging of Beoplay M5. If these options are not available, gently pull the cylindrical speaker cover down and lift Beoplay M5 up from the cover. You will find a sticker on the back that shows the 8-digit serial number.