A flat overhand bend in the elastic cord is what I recommend: https://www.animatedknots.com/flat-overhand-bend-knot
Justification:
Simple, not bulky, reasonably secure against shaking loose, and relatively easy to untie.
As suggested in another comment, a double figure eight could be used as well. It will be more bulky and a bit less likely to come loose.
If you want to be able to trim off the ends, I suggest a double fisherman’s instead (aka the double overhand stopper) with both strands (hold them together while you tie and treat them as a single strand).
https://www.animatedknots.com/double-overhand-stopper-knot
With either knot, after you trim, you can melt the ends of the elastic cord. It will “mushroom” a bit, which will also prevent the tips from creeping into the knot and coming loose.