Novice question: debugging a package fix: can I locally override just a single line of a long multi-line string in a package?

The simplest solution would be cloning Nixpkgs locally (e.g. to ~/Projects/nixpkgs) and just modifying the file directly. Then, you will be able to build the derivation in the ~/Projects/nixpkgs directory with nix-build --expr 'let pkgs = import ./. {}; in pkgs.dictDBCollector { dictlist = []; }'' or nix repl. You can even rebuild your system with this copy of Nixpkgs by passing -I nixpkgs="$HOME/Projects/nixpkgs" to nixos-rebuild (or --override-input "$HOME/Projects/nixpkgs" with Flakes).

Alternately, stdenv.mkDerivation from Nixpkgs allows you to create modified derivations using overrideAttrs function. You could use it from e.g. repl without modifying any files.

But you would have to call that on the result of mkDerivation:

(pkgs.dictDBCollector { dictlist = []; }).overrideAttrs (attrs: { installPhase = builtins.replaceStrings ["--locale "] ["--locale="] attrs.installPhase; })

Just note that since this is a higher-lever Nixpkgs construct, it might not update all Nix references for you:

nix-repl> ((stdenv.mkDerivation rec { pname = "foo"; version = "1.2.3"; meta.changelog = "http://foo/${version}"; }).overrideAttrs {version = "2.0";}).meta.changelog
"http://foo/1.2.3"