So you would have to create an output dataset that does the persisting - simple node that accepts the data and then outputs to a new dataset that gets persisted.
What you can do is an
after_pipeline_created
hook that replaces the dataset with a MemoryDataSet dynamically based on the parameter or env variable