Can a reaction of the form A + B → AB ever be endothermic?
A bond does not simply form because two atoms are close enough. You also have to bring them into the right electronic state to do so. Which takes various amounts of energy. So yes, an A+B -> AB reaction can be endothermic.

Also beware of mistaking the abscissa in those energy diagrams as a distance: It's usually just a symbolic "reaction progress", or it is a line on a multidimensional hypersurface describing the energy potential with respect to all angles, distances, electronic parameters etc. in the reaction.