youYou are not farefar away, just some lines of code:
lyr = iface.activeLayer()
fts = lyr.getFeatures()
lyr.startEditing()
for f in fts:
f['myfield']='mystring'
lyr.updateFeature(f)
lyr.commitChanges() #ends the editing session and commit all changes
for some good examples see:
https://anitagraser.com/pyqgis-101-introduction-to-qgis-python-programming-for-non-programmers/pyqgis101-creating-editing-a-new-vector-layer/
or
https://docs.qgis.org/3.4/en/docs/pyqgis_developer_cookbook/