First and foremost, you would want to wedge the cot in against the bed. We had the bed pushed against the cot which was then pushed against my dressing table, which was then pushed against a wall.
Not sure how well I have explained that but you don't just want the bed positioned next to the cot and that's it. Because when you have a crafty quickie with DH move around in bed, the cot and bed jiggle away from each other. So wedge it in first.
You can also cable-tie the legs/casters of the bed to the legs of the cot.
Then, if you google you will find some people go whole-hog and buy some foam mattress and cut a piece exactly to size to cover the gap. I don't go that far.
I use a rolled-up cot blanket between the gap. A rolled towel does the same or, as PP said, a swimming noddle works nicely.