RXJS Observable, with a dynamic function pipe

I’m trying to return an observable with a pipe that gets populated every time it gets called.
To demonstrate what exactly this means, look at the example below:

const myObservable = timer(1000);
return myObservable.pipe(getCustomPipe());
function getCustomPipe() {
   return condition ? pipe(1,2,3) : pipe(4,5,6)
}

What actually happens in my current approach, getCustomPipe() is called once and the result kept into the observable pipe without calling it again, and this is expected as I’m calling the function inside the pipe without introducing some kind of pipe factory function.

How it should be:

return myObservable.pipe(
    mergePipe(() => getCustomPipe())
);

// mergePipe is an imaginary pipe factory

Is there any solution for this kind of pipe problem?