Giving consent is not the only legal basis for processing of personal data. Article 6(1) GDPR lists all situations where processing of personal data is allowed.
If I understand your question correctly, Company A has a learning platform to teach about the products it sells. Company B buys products from Company A. Company B wants its employees to know how to use those products.
In that case Company B has a legitimate interest to add its employees to the learning platform. This is condition (f) of Article 6:
Processing shall be lawful only if and to the extent that at least one of the following applies:
(f) processing is necessary for the purposes of the legitimate interests pursued by the controller or by a third party, except where such interests are overridden by the interests or fundamental rights and freedoms of the data subject which require protection of personal data, in particular where the data subject is a child.
Because you say it are pharmaceutical products, there might also be a legal obligation because prescribing a wrong product is dangerous. But I don't know if that is the case.
Also note that in many EU countries, consent would not even be possible because there is a imbalanced relationship between an employer and an employee, see for example the ICO website or this page from the European Commission:
The employer-employee situation is generally considered as an imbalanced relationship in which the employer wields more power than the employee. Since consent has to be freely given, and in light of the imbalanced relationship, your employer in most cases can’t rely on your consent to use your data.
But besides that, the GDPR also requires data minimisation. See Article 5(1)(c):
Personal data shall be:
(c) adequate, relevant and limited to what is necessary in relation to the purposes for which they are processed (‘data minimisation’);
Possibly, instead of the employee's name, a pseudonym could be used to reach the same goal. But there might also be reasons a pseudonym could not be used, for example if at the end of the course a certificate is received which lists the employee's name.
However, it might be unlawful if a personal email address is used instead of a company email address. In particular because that email address was not collected for that purpose.