I am just wondering because I have one in my 40 breeder, and we originally planned on getting another 40 breeder and sectioning an area off until she grows, but there were none at multiple stores so we just bought a 20 long until the next dollar per gallon sale, and I don't want to get an 18" light and fixture if it's only going to be about a month or two with her in there, but if I really really have to, I will. I just hope I don't haha.
Yes, since it's only temporary. I had to do that when my guys were babies, because I didn't see the point in buying 18" bulbs only to not be able to transfer them into their grown-up enclosures a couple of months later. Just make sure you put a hide in there so your beardie can get out of the UVB that way if they really want to.
24" is ideal for a 40g because then it is 2/3 the length of the viv. Ideally, you want your UVB to run 1/2-2/3 the length of the viv over against the basking side. That way your beardie can escape the UVB over on the cools side if he/she wants. Since the original poster only intends the 20g to be a temporary enclosure, I think it will be fine so long as they provide their beardie with a hide to get out of the UVB.
A 40g breeder is 36" long, so if you have the 24" all the way over against the warm side, then there should be 12" of cool side that's not directly under the UVB.