I can’t find a clear answer about custom tags (these links suggest you can with a third party tool), but looking at the specifications gives only the defined tags so I’m going to say no, you can’t make your own metadata tags, at least not directly.
So what you can do is write your own data to any of the defined tags. It’s best to use the MakerNote tag for this - most camera makers store their own custom metadata there. Dump your custom flags into a byte string before stuffing it into the MakerNote tag:
from PIL import Image
import piexif
import pickle
tags = {'url_current' : 'https://stackoverflow.com/q/52729428/1846249',
'contains_fish' : False,
3 : 0.14159265358979323, }
data = pickle.dumps(tags)
exif_ifd = {piexif.ExifIFD.MakerNote: data}
exif_dict = {"0th": {}, "Exif": exif_ifd, "1st": {},
"thumbnail": None, "GPS": {}}
img = Image.new('RGB', (500, 500), 'green')
exif_dat = piexif.dump(exif_dict)
img.save('image.jpg', exif=exif_dat)
Because it's your own format, you'll need to read it back out yourself:
img = Image.open('image.jpg')
raw = img.getexif()[piexif.ExifIFD.MakerNote]
tags = pickle.loads(raw)
exiftool will see the image has a MakerNote, but won't recognize it:
C:\> exiftool image.jpg -MakerNote
Warning: [minor] Unrecognized MakerNotes - image.jpg
You could also store it in the UserComment tag - storing is done in the same way.
C:\>exiftool image.jpg -UserComment
User Comment : Ç.ò^}ö(î.url_currentöî,https://stackoverflow.com/q/52729428/1846249öî.contains_fishöëK.G?┬.╡DB╤äu.
P.S. there's a limit of 64kB for metadata in jpeg images