I am think about changing to a 1xN drivetrain, and I was wondering if I needed to change the chain as well.
As others have mentioned, if your chain is worn out yes.
But most importantly:
If your conversion involves a change in the number of gears of the cassette (which is the majority of the case), you'll need a new chain anyway. Chains are designed for a given number of gears on the cassette, you can't use a 10-speed chain on a 12 speed cassette.
Another reason is that the chain length can change: if your bike has for example a 2x with 36/22 chainring in the front and an 11/36 cassette, you will need a longer chain if you upgrade to a 32T chainring (or bigger) and a 11/51 cassette(around 20 additional links, so that not insignificant).
Assuming you are buying and installing new chainrings or cassette, and the chain is used then yes, because (1) it is cheap, and (2) a worn chain will wear new gears faster, and (3) if the chain wear is significantly off from the gears the chain can skip under load which can be a safety hazard.
The chain is generally the least expensive part of the drivetrain. If you are installing a new chainring or cassette, you are probably already investing a significant amount it the new set up, probably a new chain will be a small part of the budget.
Importantly, the chain will wear over time and effectively stretch out. So the distance between the pins will increase. Fewer teeth will take more of the load as the chain continues to wear. This wears the teeth of the gears and the chain faster, as the load is increasingly concentrated on fewer points of contact. You can tell if the teeth are worn by looking at them usually, but you need a tool to measure chain wear.
A worn chain will not match as well with the gears as a new chain (same for new chain and used gears), and will accelerate wear on more expensive components. In the worst case the chain will slip entirely from the gears. Considering the price of new gears and the expectation that the new drivetrain lasts as long as possible, it probably makes sense to get a new chain if upgrading any other drivetrain components.
If you're not sure how worn your chain is it might be worth it to ask a shop to measure it for you and give you a recommendation based on that, or better yet pick up a chain measuring tool at the bike shop and then you can measure the chain any time want, and really optimize the lifespan of the cassette and chainrings.