Place the espresso and water (or strong coffee) in a small pan with the sugar and vanilla, if using. Warm gently to dissolve the sugar then set aside to cool. Once lukewarm, transfer to the fridge to chill completely.
Once the coffee mixture is cold, pour into a shallow container such as a loaf tin and place in the freezer. Remove from the freezer roughly every 30 minutes and break up the ice with a fork - initially you more mash it from the edges, then as it freezes more you fluff it up a little to get some air between the ice crystals.
After around 2 hours, it should be pretty well frozen. Break up the ice crystals one last time then serve, traditionally in a clear glass and often topped with some whipped cream.
Video
Notes
If you don't have espresso then use 1 cup/240ml strong coffee instead eg cafetière/French press style.