You can create a memory layer ( always editable) with your GeoJSON geometry. The problem is that PyQGIS does not know this format for that but there are other solutions.
1) Direct transformation of the GeoJSON coordinates to a QGIS polygon:
geojson= {"type":"MultiPolygon","coordinates":[[[[540776.621887207,5912792.64251709],[540773.4404907227,5912798.570678711],[540774.3524780273,5912833.500305176],[540773.7451171875,5912839.8787231445],[540781.3389282227,5912846.864685059],[540789.8435058594,5912855.673095703],[540800.170715332,5912865.088500977],[540805.637878418,5912877.541870117],[540806.8529052734,5912887.261291504],[540804.4237060547,5912900.322509766],[540796.8306884766,5912932.8220825195],[540795.3120727539,5912966.841308594],[540800.7799072266,5912984.76171875],[540803.6392822266,5912983.147521973],[540799.428527832,5912964.180908203],[540801.6641235352,5912931.578491211],[540808.3139038086,5912901.5205078125],[540812.0502929688,5912888.047912598],[540810.8626708984,5912876.851501465],[540805.3167114258,5912862.604125977],[540796.9296875,5912854.176513672],[540787.0308837891,5912844.229919434],[540777.3010864258,5912836.084289551],[540776.621887207,5912792.64251709]]]]}
geom = QgsGeometry.fromPolygon([[QgsPoint(pt[0],pt[1]) for pt in geojson['coordinates'][0] [0]]])
2) Use of other Python modules (transformation of the GeoJSON geometry to WKT (or WKB)):
With geomet:
from geomet import wkt
geom = QgsGeometry.fromWkt(wkt.dumps(a, decimals=4))
With Shapely
from shapely.geometry import MultiPolygon, shape
geom = shape(geojson)
geom = QgsGeometry.fromWkt(geom.wkt)
With OGR:
from osgeo import ogr
import json
string = json.dumps(geojson)
geom = ogr.CreateGeometryFromJson(str)
geom = QgsGeometry.fromWkt(point.ExportToWkt())
3) after that you can create a memory layer (editable)
layer = QgsVectorLayer('Polygon','test','memory')
pr = layer.dataProvider()
elem= QgsFeature()
elem.setGeometry(geom)
pr.addFeatures( [ elem ] )
layer.updateExtents()
QgsMapLayerRegistry.instance().addMapLayers([layer])
Best Answer
To load a shapefile into QGIS and set the layer as "editable", I executed the code below in the Python Concole:
For PostGIS tables this blog post may help to set up the SELECT statement in order to load the PostGIS table successfully. Once the layer has been loaded into QGIS I assume the code below will enable/disable editing:
I have not tried the PostGIS example yet. This is my first post on GIS StackExchange so I hope it helps.