Custom Infill Pattern Based on Self-Generated Geometry
From my experience, this is hard, particularly because slicers are not made to handle it well. They generally do their infill generation efficiently in terms of 2D geometry, built as a function of the layer height and the outline(s) in the layer. Of course you can actually make the infill pattern part of your model geometry, or use a separate model intersected with the interior of your model as the infill, but having the infill structure be 3D geometry means that the slicer will be quantizing it to layers, and will have a hard time generating exactly-one-line-thickness extrusions that print will for the infill cross sections.
If you do want to do this anyway, OpenSCAD provides the tools to do the necessary intersection of your generated geometry pattern with the model interior.