A scan will help, but doesn't always point to the root issue. A few ideas below..just shoot'n in the breeze here:
IDK if this would do it, but on the older trucks there is a fuel pressure regulator down by the brake booster. Those can flake-out or fail and result in a long crank or a no-start. But IDK what they used in 2021. You might go to Youtube and type in Ram fuel pressure regulator...and have a look. See if it resembles your issue. They're not to difficult to replace.
Otherwise, the first thought which came to my mind was the WIN module. (another item to youtue).
OR... possibly ...oil pressure sending unit (or connector). Most vehicles want to see oil pressure rise on crank, and can result in a long-crank if they don't.
Worth removing the air intake snorkel and check your truck's throttle body for deposits around the butterfly valve. Simple but often-overlooked maintenance. It only takes a little build-up to goof things up. Probably not it, but only takes a couple minutes to check (and it's free to check). Clean with a soft plastic brush and some Throttle Body Cleaner ....and the back of the butterfly valve too. Prop the valve open and let sit a while for the solvent to evaporate.
Just throwing out ideas here. So you took it to a dealer and they weren't able to figure it out? I would ask to have their BEST TECH look at it. Dealerships have a range of technicians with different skill levels. A lot of time you get the intermediate guy. Find out who their best master tech is and make sure on the day you take your truck in...he's the one looking at it (not the guy they'd let go in a minute ...if they could). Usually most dealers have one super-tech who really gets into his work..reads as much as he can, knows 3x more than the others. They're super busy ...and this is the kind of job for a guy like that.