STM32F042K6U6 BOOT0 pin? Can not understand how to program it with DFU mode
All packages have a pin having the BOOT0 role which must at reset be correctly driven for the desired startup mode, regardless if you ever plan to change that or not.

If the pin is also available as a GPIO then you would need to keep your GPIO usage compatible with an approach such as having a pulling resistor that sets the state at reset, after which you are free to override the pulling resistor with a different input or output state - of course you must keep in mind the power cost of of asserting a signal against a pulling resistor.

That said it would be a severe mistake to design yourself a board with no means of access to the two key SWD signals, and really nRST and a UART too.  Take them only as far as pads you can solder under a microscope or preferably hit with a pogo fixture, but don't skip them.  There are just too many development possibilities you give up if you do.