How to make object A a parent(keep_transform) of object B via Blender's Python API?
If you want to retain the transformation of the child you can do this:

 b.parent = a
 b.matrix_parent_inverse = a.matrix_world.inverted()




You need to update depsgraph after creating the empty (matrix_world of the newly created object is updated after updating depsgraph):

import bpy # sin esta libreria no funcionan los comandos en blender
techos = bpy.context.selected_objects

for i in techos:
    #bpy.ops.object.empty_add(type='PLAIN_AXES',radius=100,location = i.location) = o

    empty = bpy.data.objects.new( "empty", None )#crea un empty y lo guarda en una variable
    bpy.context.scene.collection.objects.link(empty)#agrega el empty a la escena
    empty.empty_display_size = 3 #da un tamaño al empty
    empty.empty_display_type = 'PLAIN_AXES'#determina la forma del empty
    empty.location = i.location #la locacion del empty es la misma que la del objeto seleccionado


    # Add this line
    bpy.context.evaluated_depsgraph_get().update()


    i.parent = empty#el objeto seleccionado es hijo del empty
    i.matrix_parent_inverse = empty.matrix_world.inverted()    

    #i.parent_set(i,keep_transform = True)
    #i.parent_set()
    print(empty)