I found the relevant part of code in an [example joomla project][1].

	public function loadLanguage($path = null)
	{
		$source = $this->parent->getPath('source');
		if (!$source)
		{
			$this->parent->setPath('source', JPATH_PLATFORM . '/' . $this->parent->extension->element);
		}
		$this->manifest = $this->parent->getManifest();
		$extension = 'lib_' . strtolower(JFilterInput::getInstance()->clean((string) $this->manifest->name, 'cmd'));
		$name = strtolower((string) $this->manifest->libraryname);
		$lang = JFactory::getLanguage();
		$source = $path ? $path : JPATH_PLATFORM . "/$name";
		$lang->load($extension . '.sys', $source, null, false, false)
			|| $lang->load($extension . '.sys', JPATH_SITE, null, false, false)
			|| $lang->load($extension . '.sys', $source, $lang->getDefault(), false, false)
			|| $lang->load($extension . '.sys', JPATH_SITE, $lang->getDefault(), false, false);
	}

But it is present in the [current joomla version][2] as well.

	public function loadLanguage($path = null)
	{
		$source = $this->parent->getPath('source');
		if (!$source)
		{
			$this->parent->setPath('source', JPATH_PLATFORM . '/' . $this->getElement());
		}
		$extension = 'lib_' . $this->getElement();
		$librarypath = (string) $this->getManifest()->libraryname;
		$source = $path ?: JPATH_PLATFORM . '/' . $librarypath;
		$this->doLoadLanguage($extension, $source, JPATH_SITE);
	}

I think the first code is easier to understand.

    $extension = 'lib_' . strtolower(JFilterInput::getInstance()->clean((string) $this->manifest->name, 'cmd'));
    $name = strtolower((string) $this->manifest->libraryname);
    $lang = JFactory::getLanguage();
    $source = $path ? $path : JPATH_PLATFORM . "/$name";

So the extension name will come from the manifest.name and not from the manifest.libraryname. I changed my code from

    <name>COM_EXAMPLE_TITLE</name>
    <libraryname>example</libraryname>

to

    <name>example</name>
    <libraryname>COM_EXAMPLE_TITLE</libraryname>

and now it works properly. Interesting that every example I read about manifest.libraryname is completely wrong about this. The current version appears to have the same trait, so if this is a bug I think it is not fixed yet.

  [1]: https://github.com/openshift/joomla-example/blob/master/php/libraries/joomla/installer/adapters/library.php#L33
  [2]: https://github.com/joomla/joomla-cms/blob/6833955cfbc0f1914751ab4c110b9b4e332eee3b/libraries/cms/installer/adapter/library.php#L161