Do you mean just a simple on/off switch? You're not talking about a DCC programming track?
If it's a siding all you need is to add an isolating joiner to one rail and feed power to that rail via a single pole on/off switch. If it's a section of track in the middle of a through line then you need an isolating joiner in one rail at each end (the same rail of course).
I did this with my line as it was designed to be used with either DC or DCC. I wanted to be able to isolate and park trains on DC, and yes it's also very useful to kill the track power while setting out or removing stock from the track. I used waterproof switch boxes to power the isolated sections. Here are a couple of photos during construction (hence track floating in the air in places

)
View attachment 300897
View attachment 300898