Everything drawn in p5.js is drawn in “immediate mode”, which means that shapes drawn to the canvas don’t have any persistent representation that can be moved around. Instead you have to manage clearing the canvas and redrawing your various shapes when parameters change such as there position or rotation.
Technically in your example the octahedron variable is a reference to the “model” but that only includes the raw geometry data, not the rotation, materials, or an other parameters used to draw it.
The answer you’re probably looking for is classes. What you can do is create an “Octahedron” class, which has its own properties that it stores. You create instances of this class that each have their own set of parameters (like position, rotation, colour, and can store its own set of data, like a 3d model)
Below an example of a cube class, that just stores data. You can also add actual functions to the class, like a “rotate()” method that adds a few degrees to its rotation variable, or a “display()” method that actually draws the cube (or in your case, octahedron).
While this is one solution, writing reusable code does not require the use of Object Oriented Programming. That said, it is a valid approach, but perhaps an example that is in the dialect that the original poster is using (p5.js) would be more helpful: