Did Gauss see the analogy between number-theoretic concepts and knots?

According to the book "Models and Inferences in Science", p.156 - "the idea of a number-theoretic approach to knots goes to Gauss (1798), who used the analogy between primes and knots, and it was put forward by Schubert (1949) and Mazur (1973)".

So, my question is where is this analogy stated in Gauss's nachlass and in addition to that, are there any indications that Gauss has foreseen the connection between his law of quadratic reciprocity and his linking integral from 1833?

The answer is no, I am afraid. Gauss's writings on knots are in scattered notes from 1794 to 1833 (some undated), none of them from 1798. On the other hand, 1798 is the year when Disquisitiones Arithmeticae was written. This, and the reference to Mazur, suggest that the book's claim is based on a casual (mis)reading of Morishita's Analogies between Knots and Primes, 3-Manifolds and Number Rings (p.2):

"As we shall see in the following, the analogy between primes and knots is well-suited with the arithmetic (for example, classfield theory) originated from Gauss' Disquisitiones Arithmeticae. Furthermore, as Gauss' linking number was connected to the electro-magnetic theory from its origin, the analogy between number theory and knot theory seems to be extended to the connection involving quantum field theory, dynamics etc (cf. [8],[28],[42] etc). I would like to e-mail Gauss in heaven and ask “Is this circle of thoughts what you dreamed to explore?”."

While Morishita's enthusiasm is infectious, "the following" (pp. 6, 18) makes clear what is already apparent on the second reading of the quote: what Morishita says "originated from" Gauss was the classfield arithmetic, not the knots-are-primes analogy. Moreover, he is explicit that by the analogy he does not mean the elementary idea (developed by Schubert in 1949) that both integers and knots can be decomposed into (connected sums of) primes, but something far more sophisticated:

"Namely, the classical classfield theory by T. Takagi - E. Artin is restated as a sort of 3-dimensional Poincare duality in the etale cohomology of a number ring ([44]). The analogy between knots and primes was firstly pointed out by B. Mazur from this homotopical viewpoint, during that time, in the middle of 1960’s (and also by Y. Manin)."

The attribution of the knots-are-primes analogy to Mazur and Manin has since been rescinded, and as a result of a Math Overflow discussion no less! With a little help, Mazur found his long lost preprint from 1964, which opens with:

"Mumford has suggested a most elegant model as a geometric interpretation of the above situation: $spec(\mathbb{Z}/p\mathbb{Z})$ is like a one-dimensional knot in $spec(\mathbb{Z})$ which is like a simply connected three-manifold."

For the full story with twists and turns see Who dreamed up the primes=knots analogy?, which also has photocopies of original sources.

Gauss's notes on knots are discussed in Colberg's Brief History of Knot Theory and Przyticki's Classical Roots of Knot Theory. His main contributions are the "Gauss code" for representing knots, and the linking integral. He did not publish on the issue, but his work was inherited by his student Listing, who developed many of Gauss's ideas in undeservedly overlooked Vorstudien zur Topologie (1847), the first publication with the word "topology" in it. Tait, the foremost explorer of knots in the 19th century, rediscovered much of it independently before Maxwell pointed out the Listing's paper to him. Unfortunately, the paper is still not translated into English, but Tait gave a detailed summary of Vorstudien. It seems that even of the more elementary "prime decomposition" analogy there is no trace in either Gauss or Listing. Listing talks about "reduced" knots, and Tait about "simple forms", but those refer to eliminating redundant crossings, not decompositions.

As for the linking integral, Gauss did not do much with it. It appears as a brief note in his diary of 1833 (published in 1867), and what little he wrote has been subject to interpretative speculations. He did not derive the integral, or noted the connection between it and the number of crossings, which appear in his "code" (it was pointed out by Boeddicker in 1876). Here is from Gauss’s Linking Number Revisited by Ricca and Nipoti:

"The concept of linking number was introduced by Gauss in a brief note on his diary in 1833 (see Sec. 2 below), but no proof was given, neither of its derivation, nor of its topological meaning. Its derivation remained indeed a mystery. Nevertheless this concept was seminal... Reconstructions of possible derivations made by Gauss have been offered by historians, in particular Epple, and physicists. These reconstructions rely on ideas that can certainly be traced back to Gauss, even though direct derivation of the linking number from Gauss’s own work is left to speculation. Here we offer a plausible reconstruction entirely based on Gauss’ own work on terrestrial magnetism..."

Ranicki has a knot theory webpage, which links to many original sources, including most of Tait's papers.