Not sure if you want to store/create the geometry or if it is just for display. Using geometry generator, you can combine two buffers the one on the exterior side and the other on the interior. The expression should be the same if using "Geometry by Expression".
To do that, you can use something like below in the expression. Caution: screenshots ...
The second one is in units of degrees. (1.86e-5 degrees ~= 2km).
Try printing the lengthUnits to verify that you're getting what you think you're getting (and then convert if you're getting map units).
Here a standalone solution where we first list styles, then make a dict to match style id to style layer name. Then, we retrieve the qgis qml style as a string. We use it in a QgsMapLayerStyle, load the qml to the layer and then refresh the canvas. Done! (PS: tested before answering ;) )
layer = iface.activeLayer()
styles = layer.listStylesInDatabase()