Instance segmentation using existing mask image

hello ml wanderers, I have a question and I would be very grateful if somebody could provide an answer or any kind of insight.
Is it possible to create instance segmentations annotations by providing an existing mask image with the segment instances already marked ?
e.g.

It all hinges on whether you already have associated annotation files that are compatible, or if you can write a script to create the necessary annotation files.

COCO JSON is a common format used for instance segmentation, for example.