Controllable morphology of flux avalanches in microstructured superconductors