You can find the quote (or something similar) in multiple places in the Théorie analytique de la chaleur, for example in
Chapter I,
paragraph (article) 14:
"L'examen de cette condition fait connaître que l'on peut développer en séries convergentes, ou exprimer par des intégrales définies, les fonctions qui ne sont point assujéties à une loi constante, et qui représentent les ordonnées des lignes irrégulières ou discontinues. Cette propriété jette un nouveau jour sur la Théorie des équations aux différences partielles, et étend l'usage des fonctions arbitraires en les soumettant aux procédés ordinaires de l'analyse."
Chapter IV, Section VI,
paragraph 219:
"Nous avons supposé jusqu'ici que la fonction dont on demande le développement en séries de sinus d'arcs multiples, peut être développée en une série ordonnée, suivant les puissances de la variable x, et qu'il n'entre dans cette dernière série que des puissances impaires. On peut étendre les mêmes conséquences à des fonctions quelconques, même à celles qui seraient discontinues et entièrement arbitraires."
paragraph 220:
"Cette remarque est importante, en ce qu'elle fait connaître comment les fonctions entièrement arbitraires peuvent aussi être développées en séries de sinus d'arcs multiples."
paragraph 229:
"Les suites formées de sinus ou de cosinus d'arcs multiples sont donc propres à représenter entre des limites déterminées, toutes les fonctions possibles, et les ordonnées des lignes ou des surfaces dont la loi est discontinue."
paragraph 278:
"[...] Ainsi ce théorême qui donne, entre des limites assignées, le développement d'une fonction arbitraire en séries de sinus ou de cosinus d'arcs multiples se déduit des règles élémentaires du calcul. [...] Dans la question suivante, on réduit encore la fonction arbitraire en une série de sinus"
Added:
After some search, I think I've finally found the source of the quote (which is not Fourier).
The phrase appear almost verbatim at the very beginning of Cornelius Lanczos's Discourse on Fourier Series (1966):
In a memorable session of the French Academy on the 21st of December 1807, the mathematician and engineer Joseph Fourier announced a thesis which inaugurated a new chapter in the history of mathematics. [...] Fourier claimed that an arbitrary function, defined in a finite interval by an arbitrary capricious graph, can always be resolved into a sum of pure sine and cosine functions.
Now the questions are: is this reconstruction historically correct? Is Fourier's claim reported accurately?
First of all, it's really hard to say that the audience considered that session to be truly memorable.
The procès-verbal of the seat is exactly the following:
M. Fourier lit un Mémoire sur la Propagation de la chaleur sur le solides.
MM: Lagrange, Laplace, Monge et Lacroix.
i.e.
Fourier reads a Memoir on Heat Propagation on Solids.
Lagrange, Laplace, Monge et Lacroix [were present].
Subsequently, a rather cold account, written by Poisson and simply signed by "P.", appears in March 1808 in the Bulletin des Sciences, where he mentions the heat equation but not the "Fourier" series.
Anyway, now we know, following Lanczos, that the claim was made by Fourier either orally during the seat of the French Academy or written in his original 1807 thesis.
The former hypothesis should be discarded, as there are no detailed records of the session, and the latter must be rejected because in the Théorie de la propagation de la chaleur dans les solides, published only in 1822 under the name of Théorie analytique de la chaleur, there's no occurrence of terms like "capricieux" or "graph(e)".
So, considering also the anachronism and the inaccuracy of a sentence such as "[a] function [...] defined [...] by an arbitrarily capricious graph", we must conclude that @Daniel J. Greenhoe's answer is correct:
Possibly what happened was that someone wrote a commentary/summary regarding Fourier's work, and then later someone else came along thinking it was an actual quote [...]
Moreover, when Lanczos want to quote exact words, also in translation, he uses quotation marks, as in the following (p. 8):
The gradual clarification of our ideas concerning the concept of a function has much to do with the discovery of Fourier in 1807. Fourier was well aware of the fact that a function need not be everywhere differentiable in order to be representable by the sum of an infinite sequence of sine and cosine functions. He talk of "arbitrary function" $y=f(x)$ which could represented by his series.
The lack of precision in his language was heavily criticised by his contemporaries, although in fact Fourier came nearer to the truth than his critics, who eanted to restrict the validity of the Fourier series to the class of infinitely differentiable functions.
Here quotation marks around arbitrary function are correct, as Fourier actually uses the expression fonctions entièrement arbitraires.
We must not blame Lanczos for this, and himself was well aware that his book was not was not a faithful account of the history of Fourier series, as reported in the foreword of the 2016 edition:
His book is not dry; a person inhabits it. "And why is it not allowed," he says in the video, "to put in a certain emotional emphasis? If you're enthused about something, why not say so?"