I personally have not done that but some people I trust say they have and it works. Just put a few drops of food coloring in the vent in the morning before she lays an egg. The egg should have light streaks of color on it when it is laid.
When the hen lays an egg she forces part of the cloaca just outside the vent to keep the egg from coming into direct contact with the other stuff that comes out of the vent. You can find some videos of this on the internet if you want to see how much actually comes out. So the egg shell is not going to pick up enough food dye to get a lot on it. The streaks might be pretty light but people I trust say they are there.
Another thing I’m not going to try, but I’ve also heard of putting different colored lipstick around a hen’s vent. That’s supposed to work but no way am I going to try explaining to my wife why I’m putting lipstick on a hen’s vent, even if I buy some specifically for that purpose and don’t use hers. You may feel more adventurist.
I don’t know why the OP wants to know which hen is laying which egg, but there could be several reasons beyond pure curiosity. You might want to know which hens are laying so you can remove freeloaders. If a hen is regularly laying a deformed egg you might want to know which hen that is. You might want to hatch a certain hen’s eggs or not want to hatch a certain hen’s egg. That information can be valuable in managing your flock.