My preferred method is to weigh them with a digital scale, males will typically be lighter than females, of course, you need to keep track of
the weights of each cocoon, and if that's the box(pictured) you have to work with, that might be time consuming. I sometimes use some label attached to the cocoon, or as with pupa, wrap it in paper towel, and I write on that.
I don't like to open cocoons, it's not always simple. I doubt there is any way to tell by sight alone. When I have opened cocoons, it has always been
stressful to me, I'll use a scissors or a razor blade, or both, and a lot can go wrong with either.