I have not tried it myself, but based on the documentation for the TileMap node, I think the following should work for detecting empty cells:
if $TileMap.get_cell(x_coord, y_coord) == $TileMap.INVALID_CELL:
print ("No tile/cell at passed in coordinates!")