Is it possible to use a post name in a custom post slug?

Rewrite is a global base for all posts under the custom post type. For example, this is the default CPT rewrite structure:

example.com/lesson/%postname%

In your code example, it’s implying you are trying to do:

example.com/%postname%-lesson/%postname%

Two issues with this idea. The first issue, assuming this functionality worked, is that your CPT urls would all be inconsistent with each other. Because the rewrite slug is global across all your custom posts, every custom post would have their own uniquely different rewrite rule which would be a nightmare to keep track of. The second issue is more relative to the fact that this idea does not work. The rewrite is literal to ‘%postname%’ meaning your post urls would all try to be accessible at exactly /%postname%-lesson/. The % character will break the url entirely and make the post inaccessible.

If you are wanting to remove the CPT slug from in front of the post name, update ‘rewrite’ to array('with_front' => false),

Then you could implementing a solution such as https://stackoverflow.com/a/4518634. Add in a check against the current post_type, and append any string you want (such as -lesson). This could allow you to achieve a permalink structure such as:

example.com/%postname%-lesson