Yes.  You can add your own samples, either to the installation directory (if you have access) or by defining the environment variable ECCODES_SAMPLES_PATH. The latter works like a normal Unix PATH where you have a colon separated list of directories for ecCodes to search when a sample is required.
One important requirement is that the sample file must have the extension ".tmpl".

To set this environment variable properly, we first have to find the samples directory used by ecCodes. For this we can use the tool codes_info which provides some configuration information about the library:

% codes_info
  ecCodes Version 2.27.0
  ...
  Default SAMPLES path is used: /usr/local/apps/eccodes/2.27.0/share/eccodes/samples
  SAMPLES path can be changed by setting ECCODES_SAMPLES_PATH environment variable

Let's say you place your own sample files in /home/eccodes/samples. We have to set the environment variable ECCODES_SAMPLES_PATH as follows:

export ECCODES_SAMPLES_PATH=/home/eccodes/samples:/usr/local/apps/eccodes/2.27.0/share/eccodes/definitions

Another cool trick is to use the codes_info tool itself for this purpose, rather than hard-coding the installation path with a specific version:

export ECCODES_SAMPLES_PATH=/home/eccodes/samples:`codes_info -s`

Refer to the codes_info help page for its options.

Now when you refer to a sample file (e.g. the C function codes_bufr_handle_new_from_samples), at run-time ecCodes will search for it in the first directory and if it is not there, it will search in the second directory (and so on)