import lxml.etree
TEST = '<html><h1>...</html>'

def insert_section(root):
    tables = root.findall('.//table')
for table in tables:
    section = ET.Element('section')
table.addprevious(section)
section.insert(0, table)
root = ET.fromstring(TEST)
insert_section(root)
print(ET.tostring(root))
Python lxml wrapping elements