Only with corrective optics
Pentax K sits 27.46mm further from the sensor than Canon EF-M. An adapter can only add distance, never remove it, so infinity focus is impossible without corrective glass in the adapter — which costs sharpness and usually a stop of light.
Coverage & framing. Canon EF-M lenses are built for a APS-C imaging circle, which is smaller than Full frame. Expect heavy vignetting or a forced crop on a Pentax K body.