You can use a metallic pot, inside of which you can bake the custard as well. If you don't have that, you can make the caramel in a regular pan and pour the caramel carefully into a casserole dish, a glass or ceramic one would be perfect.
Either way, add the sugar to the pot or pan. Let it untouched until it starts to melt, then start stirring carefully.
Let it caramelize until it reaches a nice amber color, but pay attention and don't let it get too dark.
For the next step, it is better to wear protective kitchen gloves, hot sugar can cause major burns. If using the metallic pot, grab it by the handles and start rotating it carefully to distribute the caramel evenly on the bottom and walls of the pan.
If using a preheated casserole dish, quickly but very carefully pour the sugar into the dish and quickly rotate the dish to distribute the caramelized sugar on the bottom and the walls of the dish. It is better to heat the casserole dish in the oven before spreading the caramel sugar in it, it will give you a few extra moments time to evenly distribute the sugar before it hardens.
Leave the pot or the dish stand for a couple of minutes until the caramel becomes hard, then pour the egg and milk mixture into the pot.