d’Alembert’s functional equation on groups