Here is an example. I haven't tested the code so there might be issues. Also it's not pretty. :D
if event is InputEventMouseButton:
if event.pressed:
var pos = event.position
var x = int(pos.x / 20)
var y = int(pos.y / 20)
var clicked_tile_pos = Vector2(x, y)
# gets the tile index from the tileset in the given position
var current_tile = map.get_cellv(clicked_tile_pos)
# sets the tile to index in the given position
map.set_cellv(clicked_tile_pos , new_tile)
Hopefully this helps.