I searched for a child lock for sliding door closet, but none of the products I found were applicable.
Eventually I found a solution using cheap drawer mechanism and a 3d printed piece. Thanks to the sliding mechanism, the lock can be pushed back far enough so that it doesn't interfere with the doors.
This model is quite specific for my built-in closet, but hopefully it will serve as an inspiration to someone.
Source model is available on onshape.
The author marked this model as their own original creation.