Super Mario Maker 2 has a somewhat hidden option to change your courses to night time. When creating a course it will start out as a day time level by default, but you can switch to the night mode in select game styles.
Place the Angry Sun on your level and then change it to the moon
If you are creating a course in Super Mario Bros, Super Mario Bros. 3, Super Mario Land, or Super Mario Bros. U, you can change your course from day to night by placing the Angry Sun enemy type on the map. This can be accessed in the parts section of the menu on the top of the screen (Press Y to access all parts).
Place the sun on your level and then use the pointer to hover over the sun and hold the A Button. This will open a new sub menu that allows you to choose between the sun and the moon. If you want to change your level to night time you can select the moon and the screen background will change automatically.
Once you have changed to night time you can erase the moon by pressing the L button.
If you’re creating a course in the Super Mario 3D World Game Style there is no Angry Sun item and no way to change the background from day to night.