You can programmatically set a cell in the TileMapTileMap class by using the set_cellset_cell function.
Note: if you're new to an engine & game dev in general, I highly recommend working through any of the tutorial information provided; I happened to come across the the link to the TileMap class in:
2d Tutorials -> Graphics -> Using TileMapsUsing TileMaps
Note: the above was for the 3.x version of Godot.
Information for the current/stable version can be found here or by changing the version in the lower left hand corner:
