So, after many hours of searching the web for an answer I managed to come up with the following code.
def get_distance_to_coast(x, y, geo_ls, coastf, epsg):
# Load coastline polygon shapefile
file = ogr.Open(coastf)
layer = file.GetLayer(0)
# Create point geometry
pt = ogr.Geometry(ogr.wkbPoint)
pt.AddPoint(x, y)
polygon = layer.GetFeature(0).GetGeometryRef()
# Reproject point to shapefile's srs
src = osr.SpatialReference()
src.ImportFromEPSG(int(epsg))
trgt = osr.SpatialReference()
trgt.ImportFromEPSG(4326)
transform = osr.CoordinateTransformation(src, trgt)
pt.Transform(transform)
# Check for intersection and distance from the closest edge
if pt.Intersection(polygon).ExportToWkt() == 'GEOMETRYCOLLECTION EMPTY' and pt.Distance(polygon) > 100:
geo_ls.append([x, y])
stat = True
else:
stat = False
return stat