I would be very hesitant to contribute money to a 401k plan that I expected to withdraw before I could do so without penalty. Does your plan allow after tax contributions and if so what are the restrictions on withdrawing these contributions? Many plans allow such contributions and they can be withdrawn at any time without penalty. Earnings on these contributions are still tax deferred. I think this would be preferable to the plan you propose. If this doesn’t work for you I suggest that a taxable account be used for this money. Remember also that under certain conditions money can be taken from a 401k plan at age 55 if this makes a difference.
Bob