How to manipulate bytea data when using backup script as a template
Instead of using...

COPY example_table (id, ip_address, domain, configuration) FROM stdin;
1   0.0.0.0 invalid.domain.com  \x7b277265666572656e63655f746f5f69705f61646472657373273a27302e302e302e30272c277265666572656e63655f746f5f646f6d61696e273a27696e76616c69642e646f6d61696e2e636f6d277d
\.


... I think you should be able to change your pattern, and do something like ...

INSERT INTO 
    example_table 
    (id, ip_address, domain, configuration) 
VALUES 
    (1, '0.0.0.0', 'invalid.domain.com', 
    $quote${"reference_to_ip_address":'0.0.0.0',
            "reference_to_domain":'invalid.domain.com'}$quote$::bytea) ;


... or, if you want to make things a little simpler, use a Common Table Expression, and you will have to change settings only in ONE place:

WITH reference_data(id, ip_address, domain) AS
(
    -- This is the only place that needs changing...
    VALUES (1, '0.0.0.0', 'invalid.domain.com')
)
INSERT INTO
    example_table 
    (id, ip_address, domain, configuration) 
SELECT
    id, ip_address, domain, 
    ('{"reference_to_ip_address":''' || ip_address || ''',' ||
     '"reference_to_domain":''' || domain || '''}')::bytea 
FROM
    reference_data ;


You can check the data

 SELECT 
     id, ip_address, domain, convert_from(configuration, 'utf8')
 FROM
     example_table ;



 id | ip_address | domain             | convert_from
 -: | :--------- | :----------------- | :-------------------------------------------------------------------------------
  1 | 0.0.0.0    | invalid.domain.com | {&quot;reference_to_ip_address&quot;:'0.0.0.0',&quot;reference_to_domain&quot;:'invalid.domain.com'}
  1 | 0.0.0.0    | invalid.domain.com | {&quot;reference_to_ip_address&quot;:'0.0.0.0',&quot;reference_to_domain&quot;:'invalid.domain.com'}