It could be done, but you would need to post-process (or actually compute) the gcode on the fly. If someone had the motivation, an Octoprint plugin could be made to do this. If it was integrated into a slicer you would just have some kind of "callback" to the slicer that would indicate that a layer ...