It is possible to replace a section of carpet if you have a piece that is large enough. To tell the truth you will be able to see the section in most cases, to see other splices look at the doorways that have carpet you can usually see a line, sometimes the “grain” of the carpet is wrong so it even shows worse.
If you have a large enough pice and want to try you can rent an seaming iron (or buy one for ~50$, seaming tape will also be needed, the place I used to rent my iron from usually had tape for .50 per foot.
Once you have your scrap, iron and tape a good sharp razor knife is needed cut your hole out. Place the scrap over the hole and rotate it 90 deg and see if one orientation looks better. Cut the scrap pice for a very tight fit.
Cut 4 strips of the seaming tape longer than the sides,
Heat the iron make sure to have a place to set it as the hot glue will mess up the carpet between pieces.
Make sure to do the most visible strip first and do the strip that will be least visible last.
Place the first strip of tape under the first edge overlapping on the back side, place the hot iron on the tape it will take a second to heat the glue but you are also heating the back of the carpet. Start pulling the iron until it reached the end pressing the carpet into the glue. Pull iron out set on tray. Wait for that to cool.
Once that is cool put another strip under and repeat, let cool, then repeat making sure to let each section cool before moving on until done.
As I said you may always see the spot but if you do a good job others may not notice it, don’t over vacuum this area it will look slightly different for a while but the beater bar on a vacuum can cause a runner, clip them if you see them at just slightly below the average height.
If you take this on let us know how it turns out. And good luck.