It's possible but difficult. It's not going to be realistic for a lot of 40 year old men. It's easier for an early 40s to get a 26-29 year than a 20-25 year old but even this is a big ask. Most men who are 40-44 don't have enough going for them to attract a 20 something, even a late 20s woman.
It would also depend upon how the 40 year old man looks for 20 something women. If he's relying upon Tinder, Hinge, or Bumble, then he won't be able to do it. Guys are fortunate to get the attention of women 1-4 years younger on apps. Women have extraordinary amounts of choices on apps, so the collective power of women on apps means a 40 year old man will often be settling for a 37-38 year old woman. An in-shape 40 year old might get an in-shape 37-38 year old on an app. The major swipe apps make it difficult to get a big age differences. Similar dynamics exist if you're trying to get vag by sending DMs on Instagram, Facebook, or LinkedIn. The newest thing is "shooting your shot" on Clubhouse, which might be the most inane thing of them all because unlike Insta, Facebook, or LinkedIn, you are not likely to be dealing with a woman in your same geographical area.
You'll need to present well in person as a 40 year old to get 20 somethings because you're most likely doing it through cold approach. With the pandemic tremendously impacting night game, you're going to have to do it through day game, which is tough. Most men don't have the stones to do day game. Day game is tough because you are approaching in random places while sober. Most 40 year old men don't have a social circle capable of introducing them to 20 something women either.
To be 40 years old and get 20 somethings, you will either have to have exceptional looks, exceptional charisma, or a solid income/net worth AND likely be sourcing her in-person.