Building onto Marvins answer,
you can keep your README.md in your usual place and include just a snippet of text.
The trick is that although Markdown does not allow to include text, it allows to include an svg-image and an svg-image can contain text that can be selected and copied in all browsers:
<svg xmlns="http://www.w3.org/2000/svg"
xml:lang="en-GB" width="auto" height="7em">
<style>
svg {
font-family: monospace;
font-size: medium;
}
</style>
<text x="0" y="1em">
<tspan x="1em" dy="1em"><dependency></tspan>
<tspan x="3em" dy="1em"><groupId>${project.groupId}</groupId></tspan>
<tspan x="3em" dy="1em"><artifactId>${project.artifactId}</artifactId></tspan>
<tspan x="3em" dy="1em"><version>${project.version}</version></tspan>
<tspan x="1em" dy="1em"></dependency></tspan>
</text>
</svg>
This will render as:
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
</dependency>
(It will become a one-liner on paste, but that's okay. pom.xml are usually auto-formatted anyway)
You put that image into a directory called "templates" and a copy into a "docimages"-directory.
Now you can add your image to the README.md using a normal image-reference:

Note you're referencing the one in your "docimages" directory, not the one in your "templates" dir.
Now you just need a job in your pom.xml that copies and filters the image's source code:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>readme-md</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.basedir}/docimages</outputDirectory>
<resources>
<resource>
<directory>${project.basedir/templates}</directory>
<includes>
<include>version.svg</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
<encoding>UTF-8</encoding>
</configuration>
</execution>
</executions>
</plugin>
"What's the benefit over filtering all of the readme?" You might ask.
Simple: A README.md can be large and can contain all kinds of variables as part of the documentation that you don't want to substitute. This will only substitute the variables in the SVG-file.