Yes. You could send the gcode commands through the r pi to the Marlin board several ways.
Save it as a file and upload it to the r pi like a 3D print job. This can be done using the Octoprint web browser interface or programmatically (PrusaSlicer does this). Then you can execute the file and it will send all of gcode commands in order.
Or you could send the gcode commands one at a time. In Octoprint there is a terminal tab that you can type commands into.
You could also write a plugin that will send any commands you want.
There are many plug ins that you can install and send custom commands as well. Macro plug in lets you create one button macros that send a bunch of commands etc…
There is a custom control plug in that will let you create any number input/output controls. you can use text boxes with buttons, slider controls, multiple choice selectors and build anything you want to send gcode to the machine.
It sort of depends on what you want to send and where you are generating the commands from.