A 40mm enlarging lens that is SPECIFICALLY DESIGNED for 35mm format works fine for that purpose.
I use sub-format lenses specifically designed for the format they are intended for: 40/4N EL Nikkor for 35mm format, 60/4 Rodagon WA for the 6 x 4.5cm up to 6 x 7cm formats, and 120/5.6 Rodagon WA for the 4” x 5” format. Each lens works perfectly for its intended format and within the maker’s stated magnification range. There is also an 80/4 Rodagon WA intended for the 6 x 9cm format. In my experience, these produce prints identical to the normal focal length lenses for each format.
The original question is different. It involves using a lens that is not only shorter then usual for the format, but more importantly, one that is NOT SPECIFICALLY DESIGNED for the format on which it’s used. It won’t properly cover larger formats at all practical magnifications. This is most noticeable at large magnifications.
It might work acceptably at small magnifications where the lens is far enough from the negative so that the film is fully covered by the lens’s circle of good definition as defined by the lens maker (most often specified by the maker as the lens’s coverage angle). The projection that extends outside of the maker’s stated coverage angle falls off radially in both definition and illumination and is considered unusable for high-quality results.