There is a controversial "trick" to pinch the very first half-cm off the bud during the mid- to late stage of flowering. This will make the plant think "i can't grow further" and will use the rest of the energy to fatten the buds and making them denser. I've came across this on here, where a grower mentioned this, and apparently this is something that commercial growers have been doing for a while to get a more consistent and dense harvest.
This is also called "back building" and there's a thread on 420magazine here: https://www.420magazine.com/community/threads/las-quick-guide-to-simple-backbuilding-technique-for-buds.209274/