When I am trying to format my pendrive, I'm getting the following error.
root@obbu-G41M-Combo:/home/obbu# mkfs.vfat -n 'Ubuntu' -I /dev/sdb1 mkfs.vfat 3.0.14 (23 Jan 2023) mkfs.vfat: unable to open /dev/sdb1: Read-only file system
Try copying all your files on the drive somewhere else. Then:
If the problem lies with the drive itself this might help. If the problem lies with the way Ubuntu is handling pen drives then we would need logs as @gertvdijk pointed out.