Using the search function for trail you can find a lot of topics about this..
usually it would consist of spawning objects by the player object at certain time-intervals or distances..
If you are using a tilemap object you might want to just remove or change tiles on overlap..